gdiplus: Set outer pointer to NULL when image loading functions fail.

This commit is contained in:
Qian Hong 2014-07-11 15:55:53 +08:00 committed by Alexandre Julliard
parent b4acc62e63
commit deb1f047a7
2 changed files with 31 additions and 3 deletions

View file

@ -1387,6 +1387,8 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromFile(GDIPCONST WCHAR* filename,
if(!filename || !bitmap)
return InvalidParameter;
*bitmap = NULL;
stat = GdipCreateStreamOnFile(filename, GENERIC_READ, &stream);
if(stat != Ok)
@ -2945,6 +2947,8 @@ GpStatus WINGDIPAPI GdipLoadImageFromFile(GDIPCONST WCHAR* filename,
if (!filename || !image)
return InvalidParameter;
*image = NULL;
stat = GdipCreateStreamOnFile(filename, GENERIC_READ, &stream);
if (stat != Ok)

View file

@ -374,24 +374,48 @@ static void test_GdipImageGetFrameDimensionsCount(void)
static void test_LoadingImages(void)
{
GpStatus stat;
GpBitmap *bm;
GpImage *img;
static const WCHAR nonexistentW[] = {'n','o','n','e','x','i','s','t','e','n','t',0};
stat = GdipCreateBitmapFromFile(0, 0);
expect(InvalidParameter, stat);
stat = GdipCreateBitmapFromFile(0, (GpBitmap**)0xdeadbeef);
bm = (GpBitmap *)0xdeadbeef;
stat = GdipCreateBitmapFromFile(0, &bm);
expect(InvalidParameter, stat);
ok(bm == (GpBitmap *)0xdeadbeef, "returned %p\n", bm);
bm = (GpBitmap *)0xdeadbeef;
stat = GdipCreateBitmapFromFile(nonexistentW, &bm);
todo_wine expect(InvalidParameter, stat);
ok(!bm, "returned %p\n", bm);
stat = GdipLoadImageFromFile(0, 0);
expect(InvalidParameter, stat);
stat = GdipLoadImageFromFile(0, (GpImage**)0xdeadbeef);
img = (GpImage *)0xdeadbeef;
stat = GdipLoadImageFromFile(0, &img);
expect(InvalidParameter, stat);
ok(img == (GpImage *)0xdeadbeef, "returned %p\n", img);
img = (GpImage *)0xdeadbeef;
stat = GdipLoadImageFromFile(nonexistentW, &img);
todo_wine expect(OutOfMemory, stat);
ok(!img, "returned %p\n", img);
stat = GdipLoadImageFromFileICM(0, 0);
expect(InvalidParameter, stat);
stat = GdipLoadImageFromFileICM(0, (GpImage**)0xdeadbeef);
img = (GpImage *)0xdeadbeef;
stat = GdipLoadImageFromFileICM(0, &img);
expect(InvalidParameter, stat);
ok(img == (GpImage *)0xdeadbeef, "returned %p\n", img);
img = (GpImage *)0xdeadbeef;
stat = GdipLoadImageFromFileICM(nonexistentW, &img);
todo_wine expect(OutOfMemory, stat);
ok(!img, "returned %p\n", img);
}
static void test_SavingImages(void)