[cairo] [cairo-commit] 3 commits - src/cairo-array.c src/cairoint.h src/cairo-types-private.h

Andrea Canciani ranma42 at gmail.com
Sun Nov 28 00:08:50 PST 2010


On Sun, Nov 28, 2010 at 4:36 AM, Bill Spitzak <spitzak at gmail.com> wrote:
> This code in the comment makes no sense to me:
>
>>>>> +    /* We allow an index of 0 for the no-elements case.
>>>>> +     * This makes for cleaner calling code which will often look like:
>>>>> +     *
>>>>> +     *    elements = _cairo_array_index_const (array, num_elements);
>>>>> +     *         for (i=0; i < num_elements; i++) {
>>>>> +     *        ... read elements[i] here ...
>>>>> +     *    }
>>>>> +     *
>>>>> +     * which in the num_elements==0 case gets the NULL pointer here,
>>>>> +     * but never dereferences it.
>>>>> +     */
>

+     *    elements = _cairo_array_index_const (array, num_elements);
should be
+     *    elements = _cairo_array_index_const (array, 0);

(same for the comment in _cairo_array_index)

Andrea


More information about the cairo mailing list