Hi,

I am not sure if this issue has already been reported. I did a quick search
and did not find a report though.

When I enable boundary check in gcc 4.6 (-Werror=array-bounds), I get an
error:

libxml2/xpath.c: In function 'xmlXPathCastNumberToString':
libxml2/xpath.c:2810:7: error: array subscript is above array bounds
[-Werror=array-bounds]

Note that I am using an arm version of the compiler. Looking at the code,
the error is here:

size = snprintf(work, sizeof(work), "%0.*f",
 fraction_place, number);
    }

    /* Remove fractional trailing zeroes */
    after_fraction = work + size;
    ptr = after_fraction;
    while (*(--ptr) == '0')
 ;
    if (*ptr != '.')
        ptr++;
    while ((*ptr++ = *after_fraction++) != 0);

    /* Finally copy result back to caller */
    size = strlen(work) + 1;
    if (size > buffersize  ) {
work[buffersize - 1] = 0;         <------------------
 size = buffersize;
    }

I don't necessarily see a problem in the code since (due to snprintf above)
when if is entered buffersize will be guaranteed to be less than or equal
to size of work, but I wanted to make sure. Do you see any issues in the
code?

 Thanks in advance,

Note: I think my first email did not go, so sorry if this is received as a
duplicate.
-Selim
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xml@gnome.org
http://mail.gnome.org/mailman/listinfo/xml

Reply via email to