Skip to content

Commit a3483e4

Browse files
committed
Fix null pointer arithmetic resulting in potential undefined behavior
NULL pointer arithmetic is undefined behaviour in c. The payload_ptr can be NULL in the moment when mpool is not initialized. References from the c11 standard: - 6.5.6 Additive operators - 6.3.2.3 Pointers Signed-off-by: Christoph Niethammer <niethammer@hlrs.de>
1 parent e547e2d commit a3483e4

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

opal/class/opal_free_list.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,9 @@ int opal_free_list_grow_st (opal_free_list_t* flist, size_t num_elements, opal_f
272272
}
273273

274274
ptr += head_size;
275-
payload_ptr += elem_size;
275+
if (NULL != payload_ptr) {
276+
payload_ptr += elem_size;
277+
}
276278
}
277279

278280
if (OPAL_SUCCESS != rc && 0 == num_elements) {

0 commit comments

Comments
 (0)