[PATCH 11/13] libfdisk: fix potentially null

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



1248:3: note: in expansion of macro 'FDISK_INIT_UNDEF'
   FDISK_INIT_UNDEF(xpa->size);
   ^~~~~~~~~~~~~~~~
libfdisk/src/partition.c:1247:15: warning: potential null pointer
dereference [-Wnull-dereference]
   xpa->resize = 0;
   ~~~~~~~~~~~~^~~
libfdisk/src/partition.c:1246:18: warning: potential null pointer
dereference [-Wnull-dereference]
   xpa->movestart = 0;
   ~~~~~~~~~~~~~~~^~~

Signed-off-by: Sami Kerola <kerolasa@xxxxxx>
---
 libfdisk/src/partition.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/libfdisk/src/partition.c b/libfdisk/src/partition.c
index 1e8c1eb32..adb4acfe4 100644
--- a/libfdisk/src/partition.c
+++ b/libfdisk/src/partition.c
@@ -1243,6 +1243,10 @@ int fdisk_set_partition(struct fdisk_context *cxt, size_t partno,
 
 	if (pa->resize || fdisk_partition_has_start(pa) || fdisk_partition_has_size(pa)) {
 		xpa = __copy_partition(pa);
+		if (xpa == NULL) {
+			rc = 1;
+			goto done;
+		}
 		xpa->movestart = 0;
 		xpa->resize = 0;
 		FDISK_INIT_UNDEF(xpa->size);
-- 
2.12.0

--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux