Module: wine Branch: master Commit: bcefe114e8fc49de5507fd01ebe08aab946533d1 URL: http://source.winehq.org/git/wine.git/?a=commit;h=bcefe114e8fc49de5507fd01eb...
Author: Aric Stewart aric@codeweavers.com Date: Thu Nov 19 07:53:04 2015 -0600
comctl32: ILC_COLORDDB imagelists can be created with 0 sizes.
Negative values are still invalid.
Signed-off-by: Aric Stewart aric@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/comctl32/imagelist.c | 5 ++--- dlls/comctl32/tests/imagelist.c | 44 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 3 deletions(-)
diff --git a/dlls/comctl32/imagelist.c b/dlls/comctl32/imagelist.c index 608ccc9..c34eb0a 100644 --- a/dlls/comctl32/imagelist.c +++ b/dlls/comctl32/imagelist.c @@ -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; diff --git a/dlls/comctl32/tests/imagelist.c b/dlls/comctl32/tests/imagelist.c index 9941667..7e029e0 100644 --- a/dlls/comctl32/tests/imagelist.c +++ b/dlls/comctl32/tests/imagelist.c @@ -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)