[Libreoffice] Array index at -1
julien
serval2412 at yahoo.fr
Sun Oct 24 05:05:44 PDT 2010
Le 24/10/2010 10:43, Norbert Thiebaud a écrit :
> On Sun, Oct 24, 2010 at 3:15 AM, julien<serval2412 at yahoo.fr> wrote:
>
>> Hi,
>>
>> I'm running cppcheck (1.45 from sourceforge since the testing package on
>> Debian repository is the 1.44 version) the whole project.
>> And i found these points :
>> [./build/libreoffice-3.2.99.2/berkeleydb/unxlngi6.pro/misc/build/db-4.7.25.NC/btree/bt_compact.c:1980]:
>> (error) Array index -1 is out of bounds
>> =>
>> epg =&cp->csp[-1];
>>
>> [./build/libreoffice-3.2.99.2/berkeleydb/unxlngi6.pro/misc/build/db-4.7.25.NC/btree/bt_delete.c:624]:
>> (error) Array index -1 is out of bounds
>> =>
>> for (epg =&cp->csp[-1]; epg>= cp->sp; epg--) {
>>
>> Are these bugs false positive or just typos ? I never saw an index to -1 but
>> i don't know at all C++.
>>
> 1/ the report is in berkleydb, which is an external library.
> So either it is a false positive, or the problem need to be reported
> upstream to the berkley db project.
>
> 2/ a cursory look at the code lead me to the conculsion that
> a/ -1 is hard coded there, and it is used as such in many places in
> that source file. It is unlikely a typo or a un-intended pre-compiler
> consequences
> b/ csp sound like 'current stack pointer' to me... and -1 would make
> sens for that kind of object.
>
> So I'd say this is most likely a false positive.
>
> Norbert
>
>
Ok, you were right, i didn't know this notation and i found this answer
in a forum (http://bytes.com/topic/c/answers/221640-negative-array-index) :
"
a[ -1 ] and *(a-1) are identical, the second being what the compiler
converts the first to (already with C89). And yes, you can access
elements of the array also with negative indexes for 'a' as long as
you stay within the limits of the array 'a' is pointing into.
"
I also read that current version of Berkeley DB was 5.1.9, do we plan to
remove this dependancy or do we stay on the 4.7.25 for the moment as it
could be long to upgrade this library, or something else (like a problem
of license even ethics since it's Oracle) ?
Julien
More information about the LibreOffice
mailing list