[xml] wrong fix in commit 14b56439



$ git show 14b56439
commit 14b5643947845df089376106517c4f7ba061e4b0
Author: Daniel Veillard <veillard src gnome org>
Date:   Thu Mar 9 18:41:40 2006 +0000

    more cleanups based on coverity reports. Daniel
    
    * relaxng.c xmlschemas.c xmlschemastypes.c: more cleanups based
      on coverity reports.

you added
        /*
         * Coverity detected an overrun in daysInMonth
         * of size 12 at position 12 with index variable "((r)->mon - 1)"
         */
        if (tmon < 0)
            tmon = 0;
        if (tmon > 12)
            tmon = 12;

but imho tmon should be 0..11 or 1..12, but not 0..12. I lean towards
0..11 as you call MAX_DAYINMONTH(tyr, tmon);
which does tmon-1.

For similar reasons I wonder about
            long tmon = (long) MODULO_RANGE((int)r->mon-1, 1, 13);
            long tyr  = r->year + (long)FQUOTIENT_RANGE((int)r->mon-1,
1, 13);
shouldn't that be either
            long tmon = (long) MODULO_RANGE((int)r->mon, 1, 13);
            long tyr  = r->year + (long)FQUOTIENT_RANGE((int)r->mon, 1, 13);
or
            long tmon = (long) MODULO_RANGE((int)r->mon-1, 0, 12);
            long tyr  = r->year + (long)FQUOTIENT_RANGE((int)r->mon-1,
0, 12);

Stefan




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]