realloc is called with a size of zero, whose result the implementation chooses
What it finds
realloc(p, 0) may free the block and return a null pointer, or return a new block of no usable size, and C23 makes it undefined; code that treats a null result as a failure then frees the block twice. free(p) says what is meant.
From the rule's source, realloc_to_zero.rs.
#include <stdlib.h> void *shrink(void *p){ return realloc(p, 0);tx0 reports: realloc with size zero may free the block or not} Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/c:realloc-to-zero" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/c:realloc-to-zero] reason="..."tx0 explain tx0/c:realloc-to-zero shows the same in the terminal. Found a false positive? Report it.