diff options
author | Sami Kerola | 2019-05-22 20:45:54 +0200 |
---|---|---|
committer | Sami Kerola | 2019-05-22 20:45:54 +0200 |
commit | 620851e0cc297c2caadf9d4480028e181d8963ee (patch) | |
tree | 88a22688ac1c692b84140f284898acd6f079b0db /libfdisk | |
parent | libfdisk: (bsd) improve checksum calculation [-Waddress-of-packed-member] (diff) | |
download | kernel-qcow2-util-linux-620851e0cc297c2caadf9d4480028e181d8963ee.tar.gz kernel-qcow2-util-linux-620851e0cc297c2caadf9d4480028e181d8963ee.tar.xz kernel-qcow2-util-linux-620851e0cc297c2caadf9d4480028e181d8963ee.zip |
libfdisk: assert if self_pte() returns NULL
The self_pte() can return NULL if partitions array is not large enough,
but that should also be impossible and definitely a bug.
libfdisk/src/dos.c:984:8: warning: potential null pointer dereference [-Wnull-dereference]
libfdisk/src/dos.c:1031:8: warning: potential null pointer dereference [-Wnull-dereference]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'libfdisk')
-rw-r--r-- | libfdisk/src/dos.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/libfdisk/src/dos.c b/libfdisk/src/dos.c index 40b9aa758..6dc276e8a 100644 --- a/libfdisk/src/dos.c +++ b/libfdisk/src/dos.c @@ -978,6 +978,8 @@ static int find_last_free_sector_in_range( last_moved = 0; for ( ; i < cxt->label->nparts_max; i++) { struct pte *pe = self_pte(cxt, i); + + assert(pe); fdisk_sector_t p_start = get_abs_partition_start(pe); fdisk_sector_t p_end = get_abs_partition_end(pe); @@ -1025,6 +1027,8 @@ static int find_first_free_sector_in_range( first_moved = 0; for (; i < cxt->label->nparts_max; i++) { struct pte *pe = self_pte(cxt, i); + + assert(pe); fdisk_sector_t p_start = get_abs_partition_start(pe); fdisk_sector_t p_end = get_abs_partition_end(pe); |