From e31e28848e7e5887b0dd48f5bb5ce3c8055eee1e Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Wed, 18 Aug 2021 11:35:07 +0200
Subject: [PATCH] libfdisk: check calloc() return [gcc-analyzer]

Signed-off-by: Karel Zak <kzak@redhat.com>
---
 libfdisk/src/ask.c  | 4 ++++
 libfdisk/src/item.c | 3 +++
 2 files changed, 7 insertions(+)

diff --git a/libfdisk/src/ask.c b/libfdisk/src/ask.c
index 31f95fb..274f6ba 100644
--- a/libfdisk/src/ask.c
+++ b/libfdisk/src/ask.c
@@ -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;
diff --git a/libfdisk/src/item.c b/libfdisk/src/item.c
index 86fa0fb..671f9ad 100644
--- a/libfdisk/src/item.c
+++ b/libfdisk/src/item.c
@@ -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;
-- 
1.8.3.1

