mirror of https://git.tukaani.org/xz.git
xz: Avoid arithmetic on a null pointer
It's undefined behavior. The result wasn't ever used as it occurred in the last iteration of a loop. Clang 17 with -fsanitize=address,undefined: $ src/xz/xz --block-list=123 src/xz/args.c:164:12: runtime error: applying non-zero offset 1 to null pointer Fixes:88ccf47205
Co-authored-by: Sam James <sam@gentoo.org> (cherry picked from commit77c8f60547
) (cherry picked from commit203d482599
)
This commit is contained in:
parent
ecbc34d90b
commit
b933ef49a5
|
@ -120,7 +120,13 @@ parse_block_list(const char *str_const)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
str = p + 1;
|
// Be standards compliant: p + 1 is undefined behavior
|
||||||
|
// if p == NULL. That occurs on the last iteration of
|
||||||
|
// the loop when we won't care about the value of str
|
||||||
|
// anymore anyway. That is, this is done conditionally
|
||||||
|
// solely for standard conformance reasons.
|
||||||
|
if (p != NULL)
|
||||||
|
str = p + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Terminate the array.
|
// Terminate the array.
|
||||||
|
|
Loading…
Reference in New Issue