gdiplus: Fix GdipGetAllPropertyItems return value when no properties exist.

Discovered in researching https://bugs.winehq.org/show_bug.cgi?id=54748
This commit is contained in:
Jeff Smith 2023-07-11 10:03:53 -05:00 committed by Alexandre Julliard
parent 1517342fac
commit b48a37f450
2 changed files with 27 additions and 27 deletions

View file

@ -2846,7 +2846,7 @@ GpStatus WINGDIPAPI GdipGetAllPropertyItems(GpImage *image, UINT size,
}
reader = ((GpBitmap *)image)->metadata_reader;
if (!reader) return PropertyNotFound;
if (!reader) return GenericError;
hr = IWICMetadataReader_GetEnumerator(reader, &enumerator);
if (FAILED(hr)) return hresult_to_status(hr);

View file

@ -3681,6 +3681,7 @@ static void test_image_properties(void)
};
GpStatus status, expected;
GpImage *image;
PropertyItem *prop_item;
UINT prop_count, prop_size, i;
PROPID prop_id[16] = { 0 };
ImageType image_type;
@ -3816,6 +3817,31 @@ static void test_image_properties(void)
status = GdipGetPropertySize(image, &prop_size, &prop_count);
expect(expected, status);
status = GdipGetAllPropertyItems(image, 0, 0, NULL);
expect(InvalidParameter, status);
status = GdipGetAllPropertyItems(image, prop_size, prop_count, NULL);
expect(InvalidParameter, status);
prop_item = HeapAlloc(GetProcessHeap(), 0, prop_size);
expected = (image_type == ImageTypeMetafile) ? NotImplemented : InvalidParameter;
if (prop_count != 1)
{
status = GdipGetAllPropertyItems(image, prop_size, 1, prop_item);
expect(expected, status);
}
if (prop_size != 0)
{
status = GdipGetAllPropertyItems(image, 0, prop_count, prop_item);
expect(expected, status);
}
status = GdipGetAllPropertyItems(image, prop_size + 1, prop_count, prop_item);
expect(expected, status);
if (image_type != ImageTypeMetafile)
expected = (prop_count == 0) ? GenericError : Ok;
status = GdipGetAllPropertyItems(image, prop_size, prop_count, prop_item);
ok(status == expected || broken(status == Ok && prop_count == 0), /* XP */
"Expected %d, got %d\n", expected, status);
HeapFree(GetProcessHeap(), 0, prop_item);
GdipDisposeImage(image);
winetest_pop_context();
@ -4176,19 +4202,6 @@ static void test_GdipGetAllPropertyItems(void)
"expected total property size %u, got %u\n", prop_size, total_size);
prop_item = HeapAlloc(GetProcessHeap(), 0, prop_size);
status = GdipGetAllPropertyItems(image, 0, prop_count, prop_item);
expect(InvalidParameter, status);
status = GdipGetAllPropertyItems(image, prop_size, 1, prop_item);
expect(InvalidParameter, status);
status = GdipGetAllPropertyItems(image, prop_size, prop_count, NULL);
expect(InvalidParameter, status);
status = GdipGetAllPropertyItems(image, prop_size, prop_count, NULL);
expect(InvalidParameter, status);
status = GdipGetAllPropertyItems(image, 0, 0, NULL);
expect(InvalidParameter, status);
status = GdipGetAllPropertyItems(image, prop_size + 1, prop_count, prop_item);
expect(InvalidParameter, status);
status = GdipGetAllPropertyItems(image, prop_size, prop_count, prop_item);
expect(Ok, status);
@ -4932,19 +4945,6 @@ static void test_gif_properties(void)
"expected total property size %u, got %u\n", prop_size, total_size);
prop_item = HeapAlloc(GetProcessHeap(), 0, prop_size);
status = GdipGetAllPropertyItems(image, 0, prop_count, prop_item);
expect(InvalidParameter, status);
status = GdipGetAllPropertyItems(image, prop_size, 1, prop_item);
expect(InvalidParameter, status);
status = GdipGetAllPropertyItems(image, prop_size, prop_count, NULL);
expect(InvalidParameter, status);
status = GdipGetAllPropertyItems(image, prop_size, prop_count, NULL);
expect(InvalidParameter, status);
status = GdipGetAllPropertyItems(image, 0, 0, NULL);
expect(InvalidParameter, status);
status = GdipGetAllPropertyItems(image, prop_size + 1, prop_count, prop_item);
expect(InvalidParameter, status);
status = GdipGetAllPropertyItems(image, prop_size, prop_count, prop_item);
expect(Ok, status);