Commit deb1f047 authored by Qian Hong's avatar Qian Hong Committed by Alexandre Julliard

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

parent b4acc62e
......@@ -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)
......
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment