Skip to content

Commit

Permalink
libfdisk: check calloc() return [gcc-analyzer]
Browse files Browse the repository at this point in the history
Signed-off-by: Karel Zak <kzak@redhat.com>
  • Loading branch information
karelzak committed Aug 18, 2021
1 parent 58b43e4 commit e826aa3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions libfdisk/src/ask.c
Expand Up @@ -36,6 +36,10 @@ int fdisk_set_ask(struct fdisk_context *cxt,
struct fdisk_ask *fdisk_new_ask(void)
{
struct fdisk_ask *ask = calloc(1, sizeof(struct fdisk_ask));

if (!ask)
return NULL;

DBG(ASK, ul_debugobj(ask, "alloc"));
ask->refcount = 1;
return ask;
Expand Down
3 changes: 3 additions & 0 deletions libfdisk/src/item.c
Expand Up @@ -40,6 +40,9 @@ struct fdisk_labelitem *fdisk_new_labelitem(void)
{
struct fdisk_labelitem *li = calloc(1, sizeof(*li));

if (!li)
return NULL;

li->refcount = 1;
DBG(ITEM, ul_debugobj(li, "alloc"));
return li;
Expand Down

0 comments on commit e826aa3

Please sign in to comment.