]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libfdisk: check calloc() return [gcc-analyzer]
authorKarel Zak <kzak@redhat.com>
Wed, 18 Aug 2021 09:35:07 +0000 (11:35 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 18 Aug 2021 09:35:07 +0000 (11:35 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
libfdisk/src/ask.c
libfdisk/src/item.c

index 31f95fb06631a300a0b43b94b30103b288d7ee73..274f6ba7b1f5870747603dca3e2a37a3157dc141 100644 (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;
index 86fa0fb1f75801e5b5f787139b78595395e29147..671f9ad38988361a0ad825971347d1715b2b8862 100644 (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;