p actually could never be 0 (because of the NULL check on the memchr() call), but the intended behavior is *p == '\0': the containing condition checks for either a truncated data (*p == '\0') or no geometry information (*p == '\n').
I replaced the check to be *p != '\n' instead of *p == '\0' to make this more robust as the actual issue is anything but a newline, the fact it can only be a NUL otherwise is incidental to the enclosing check, but not really relevant at this level. This is also in line with the actual error message.
p
actually could never be0
(because of the NULL check on thememchr()
call), but the intended behavior is*p == '\0'
: the containing condition checks for either a truncated data (*p == '\0'
) or no geometry information (*p == '\n'
).I replaced the check to be
*p != '\n'
instead of*p == '\0'
to make this more robust as the actual issue is anything but a newline, the fact it can only be a NUL otherwise is incidental to the enclosing check, but not really relevant at this level. This is also in line with the actual error message.Found by cppcheck: https://caja.mate-desktop.dev/2022-11-23-174623-5790-cppcheck@ae663c369cf2_desktop-no-overflow/16.html#line-204
Normally you won't see any change in any case, unless you manage to drop invalid data somehow.