libfdisk: check calloc() return [gcc-analyzer]

Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
Karel Zak 2021-08-18 11:35:07 +02:00
parent 58b43e4b4f
commit e826aa3f49
2 changed files with 7 additions and 0 deletions

View File

@ -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;

View File

@ -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;