Add some null checking in the Get/SetBitmapBits functions.

This commit is contained in:
Pascal Lessard 1999-05-22 10:39:00 +00:00 committed by Alexandre Julliard
parent 090e2d873e
commit 8903e536fb
1 changed files with 6 additions and 1 deletions

View File

@ -245,6 +245,10 @@ LONG WINAPI GetBitmapBits(
if (!bmp) return 0; if (!bmp) return 0;
/* If the bits vector is null, the function should return the read size */
if(bits == NULL)
return bmp->bitmap.bmWidthBytes * bmp->bitmap.bmHeight;
if (count < 0) { if (count < 0) {
WARN_(bitmap)("(%ld): Negative number of bytes passed???\n", count ); WARN_(bitmap)("(%ld): Negative number of bytes passed???\n", count );
count = -count; count = -count;
@ -318,7 +322,8 @@ LONG WINAPI SetBitmapBits(
BITMAPOBJ *bmp = (BITMAPOBJ *) GDI_GetObjPtr( hbitmap, BITMAP_MAGIC ); BITMAPOBJ *bmp = (BITMAPOBJ *) GDI_GetObjPtr( hbitmap, BITMAP_MAGIC );
LONG height, ret; LONG height, ret;
if (!bmp) return 0; if ((!bmp) || (!bits))
return 0;
if (count < 0) { if (count < 0) {
WARN_(bitmap)("(%ld): Negative number of bytes passed???\n", count ); WARN_(bitmap)("(%ld): Negative number of bytes passed???\n", count );