This is the mail archive of the
mailing list for the elfutils project.
Re: [PATCH] libdwfl: Correct off-by-one check in segment.c insert.
- From: Mark Wielaard <mjw at redhat dot com>
- To: elfutils-devel at lists dot fedorahosted dot org
- Date: Tue, 07 Apr 2015 18:34:42 +0200
- Subject: 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?