In buffer.c, in the function drop_volume_label_suffix, around line
1583 the expression "p - (VOLUME_TEXT_LEN - 1)" is ill-defined
according to the C language model (since you can't create a pointer
that goes beyond the boundary of an allocation without triggering
UB).

It doesn't appear to CURRENTLY be a problem, but an aggressive
optimizing compiler that does value propagation would be perfectly
entitled to drop the test altogether:

label appears to always be storage allocated through xmalloc, p points
within that storage, and in order to be "well defined" that expression
CANNOT go below label, so the test could be flagged as always true.

The test could be rearranged as "p - label > VOLUME_TEXT_LEN-1"
which is well defined.

(might require a cast, since p - label is ptrdiff_t hence signed,
whereas VOLUME_TEXT_LEN is unsigned)

Reply via email to