Re: [AD] Zero sized bitmaps

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


what if after you create a 0x1 or 1x0 (which ever it was that was allowed) and you attempt to access the ->line[] will that cause a crash ?

i'd prefer to return NULL for bitmaps 0x1 or 1x0 sized bitmaps.






Matthew Leverton wrote:
Chris wrote:

extra memory for the line[] array). A proper fix (if you don't want to return
NULL), would simply be:

if (height>0) {
 bitmap->line[0] = bitmap->dat;
 for (i=1; i<height; i++)
    bitmap->line[i] = bitmap->line[i-1] + width *
                      BYTES_PER_PIXEL(color_depth);
}



I created a patch from the above code and tested under MSVC 8. It no
longer crashes when destroying 0x0 bitmaps. I don't care which route
is taken, as long as any non NULL bitmap passed back to the user can
be destroyed without a crash. :)

--
Matthew Leverton





Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/