This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]