[PATCH] libdwfl: Correct off-by-one check in segment.c insert.

Mark Wielaard mjw at redhat.com
Tue Apr 7 16:34:42 UTC 2015


On Mon, 2015-04-06 at 12:45 -0700, Roland McGrath wrote:
> Usually "x + 1 >= y" should be "x > y", no?

Do you mean x >= y - 1?

The check is for whether there is a next element (x + 1) in the array
(size y). If not the array will need extending. If there is such an
element we check whether it already marks the end.

The bug was accessing that array element if it didn't exist to see
whether we needed a new end marker. I am writing that as i + 1 >=
dwfl->lookup_elts because if that is not true we'll access
dwfl->lookup_addr[i + 1]. So the i + 1 check looks symmetric.

Or am I missing something?

Thanks,

Mark


More information about the elfutils-devel mailing list