Commit bcefe114 authored by Aric Stewart's avatar Aric Stewart Committed by Alexandre Julliard

comctl32: ILC_COLORDDB imagelists can be created with 0 sizes.

Negative values are still invalid. Signed-off-by: 's avatarAric Stewart <aric@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 499f0454
......@@ -776,7 +776,8 @@ ImageList_Create (INT cx, INT cy, UINT flags,
TRACE("(%d %d 0x%x %d %d)\n", cx, cy, flags, cInitial, cGrow);
if (cx <= 0 || cy <= 0) return NULL;
if (cx < 0 || cy < 0) return NULL;
if (!((flags&ILC_COLORDDB) == ILC_COLORDDB) && (cx == 0 || cy == 0)) return NULL;
/* Create the IImageList interface for the image list */
if (FAILED(ImageListImpl_CreateInstance(NULL, &IID_IImageList, (void **)&himl)))
......@@ -1831,8 +1832,6 @@ ImageList_GetIconSize (HIMAGELIST himl, INT *cx, INT *cy)
{
if (!is_valid(himl) || !cx || !cy)
return FALSE;
if ((himl->cx <= 0) || (himl->cy <= 0))
return FALSE;
*cx = himl->cx;
*cy = himl->cy;
......
......@@ -1964,7 +1964,11 @@ static void test_iconsize(void)
static void test_create_destroy(void)
{
HIMAGELIST himl;
IImageList *imgl;
INT cx, cy;
BOOL rc;
HRESULT hr;
INT ret;
/* list with zero or negative image dimensions */
himl = ImageList_Create(0, 0, ILC_COLOR16, 0, 3);
......@@ -1984,6 +1988,46 @@ static void test_create_destroy(void)
rc = ImageList_Destroy((HIMAGELIST)0xdeadbeef);
ok(rc == FALSE, "ImageList_Destroy(0xdeadbeef) should fail and not crash\n");
/* DDB image lists */
himl = ImageList_Create(0, 14, ILC_COLORDDB, 4, 4);
ok(himl != NULL, "got %p\n", himl);
imgl = (IImageList*)himl;
IImageList_GetIconSize(imgl, &cx, &cy);
ok (cx == 0, "Wrong cx (%i)\n", cx);
ok (cy == 14, "Wrong cy (%i)\n", cy);
ImageList_Destroy(himl);
himl = ImageList_Create(0, 0, ILC_COLORDDB, 4, 4);
ok(himl != NULL, "got %p\n", himl);
imgl = (IImageList*)himl;
IImageList_GetIconSize(imgl, &cx, &cy);
ok (cx == 0, "Wrong cx (%i)\n", cx);
ok (cy == 0, "Wrong cy (%i)\n", cy);
ImageList_Destroy(himl);
himl = ImageList_Create(0, 0, ILC_COLORDDB, 0, 4);
ok(himl != NULL, "got %p\n", himl);
imgl = (IImageList*)himl;
IImageList_GetIconSize(imgl, &cx, &cy);
ok (cx == 0, "Wrong cx (%i)\n", cx);
ok (cy == 0, "Wrong cy (%i)\n", cy);
hr = IImageList_SetImageCount(imgl, 3);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IImageList_GetImageCount(imgl, &ret);
ok(hr == S_OK && ret == 3, "invalid image count after increase\n");
/* Trying to actually add an image causes a crash on Windows */
ImageList_Destroy(himl);
/* Negative values fail */
himl = ImageList_Create(-1, -1, ILC_COLORDDB, 4, 4);
ok(himl == NULL, "got %p\n", himl);
himl = ImageList_Create(-1, 1, ILC_COLORDDB, 4, 4);
ok(himl == NULL, "got %p\n", himl);
himl = ImageList_Create(1, -1, ILC_COLORDDB, 4, 4);
ok(himl == NULL, "got %p\n", himl);
}
static void test_IImageList_Clone(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