From: Karel Zak Date: Wed, 18 Aug 2021 09:15:55 +0000 (+0200) Subject: libfdisk: dereference of possibly-NULL [gcc-analyzer] X-Git-Tag: v2.38-rc1~287 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c36203873f8dd87e8561c50fba5e4f4b5b0170c2;p=thirdparty%2Futil-linux.git libfdisk: dereference of possibly-NULL [gcc-analyzer] Signed-off-by: Karel Zak --- diff --git a/libfdisk/src/parttype.c b/libfdisk/src/parttype.c index 3a5db9c288..271b671464 100644 --- a/libfdisk/src/parttype.c +++ b/libfdisk/src/parttype.c @@ -26,6 +26,9 @@ struct fdisk_parttype *fdisk_new_parttype(void) { struct fdisk_parttype *t = calloc(1, sizeof(*t)); + if (!t) + return NULL; + t->refcount = 1; t->flags = FDISK_PARTTYPE_ALLOCATED; DBG(PARTTYPE, ul_debugobj(t, "alloc"));