comctl32-LoadIconMetric: Set *icon to NULL on invalid size argument in LoadIconMetric.

This commit is contained in:
Sebastian Lackner 2015-10-02 16:28:29 +02:00
parent f9edeb7354
commit 6ef9e97ec1
2 changed files with 17 additions and 11 deletions

View File

@ -1,4 +1,4 @@
From 2994442796e915f6b6704f904ea36430257fb977 Mon Sep 17 00:00:00 2001
From 3e453d9acebccfdcd209dbc57130bdfcaeb154ce Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Thu, 1 Oct 2015 22:52:22 +0200
Subject: comctl32: Add implementation for LoadIconMetric.
@ -9,9 +9,9 @@ Content-Transfer-Encoding: 8bit
Signed-off-by: Michael Müller <michael@fds-team.de>
---
dlls/comctl32/comctl32.spec | 1 +
dlls/comctl32/commctrl.c | 25 +++++++++++++++++++++++++
dlls/comctl32/commctrl.c | 28 ++++++++++++++++++++++++++++
include/commctrl.h | 7 +++++++
3 files changed, 33 insertions(+)
3 files changed, 36 insertions(+)
diff --git a/dlls/comctl32/comctl32.spec b/dlls/comctl32/comctl32.spec
index 1e92e5f..1a5ab57 100644
@ -26,10 +26,10 @@ index 1e92e5f..1a5ab57 100644
382 stdcall -noname SmoothScrollWindow(ptr)
383 stub -noname DoReaderMode
diff --git a/dlls/comctl32/commctrl.c b/dlls/comctl32/commctrl.c
index 97656a5..22281e1 100644
index 97656a5..6d6b5e4 100644
--- a/dlls/comctl32/commctrl.c
+++ b/dlls/comctl32/commctrl.c
@@ -1658,3 +1658,28 @@ HRESULT WINAPI LoadIconWithScaleDown(HINSTANCE hinst, const WCHAR *name, int cx,
@@ -1658,3 +1658,31 @@ HRESULT WINAPI LoadIconWithScaleDown(HINSTANCE hinst, const WCHAR *name, int cx,
return S_OK;
}
@ -54,7 +54,10 @@ index 97656a5..22281e1 100644
+ cy = GetSystemMetrics(SM_CYICON);
+ }
+ else
+ {
+ *icon = NULL;
+ return E_INVALIDARG;
+ }
+
+ return LoadIconWithScaleDown(hinst, name, cx, cy, icon);
+}

View File

@ -1,4 +1,4 @@
From 7c5c210415b7506d2c9328561ceda0cf8b821c1f Mon Sep 17 00:00:00 2001
From 21c232611559de13e52d933ffd5f940230bbad86 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Thu, 7 Aug 2014 01:54:28 +0200
Subject: comctl32/tests: Add tests for LoadIconMetric function.
@ -8,11 +8,11 @@ Content-Transfer-Encoding: 8bit
Signed-off-by: Michael Müller <michael@fds-team.de>
---
dlls/comctl32/tests/misc.c | 150 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 150 insertions(+)
dlls/comctl32/tests/misc.c | 153 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 153 insertions(+)
diff --git a/dlls/comctl32/tests/misc.c b/dlls/comctl32/tests/misc.c
index 280b46c..ea2181d 100644
index 280b46c..ffd0dca 100644
--- a/dlls/comctl32/tests/misc.c
+++ b/dlls/comctl32/tests/misc.c
@@ -20,6 +20,7 @@
@ -42,7 +42,7 @@ index 280b46c..ea2181d 100644
#define COMCTL32_GET_PROC(ordinal, func) \
p ## func = (void*)GetProcAddress(hComctl32, (LPSTR)ordinal); \
if(!p ## func) { \
@@ -205,6 +218,142 @@ static void test_TaskDialogIndirect(void)
@@ -205,6 +218,145 @@ static void test_TaskDialogIndirect(void)
ok(ptr == ptr2, "got wrong pointer for ordinal 345, %p expected %p\n", ptr2, ptr);
}
@ -71,6 +71,7 @@ index 280b46c..ea2181d 100644
+ if (!pLoadIconMetric || !pLoadIconWithScaleDown)
+ {
+ win_skip("LoadIconMetric or pLoadIconWithScaleDown not exported by name\n");
+ FreeLibrary(hinst);
+ return;
+ }
+
@ -93,8 +94,10 @@ index 280b46c..ea2181d 100644
+ "got wrong pointer for ordinal 381, %p expected %p\n", ptr, pLoadIconWithScaleDown);
+
+ /* invalid arguments */
+ icon = (HICON)0x1234;
+ hr = pLoadIconMetric(NULL, MAKEINTRESOURCEW(IDI_APPLICATION), 0x100, &icon);
+ ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %x\n", hr);
+ ok(icon == NULL, "Expected NULL, got %p\n", icon);
+
+ icon = (HICON)0x1234;
+ hr = pLoadIconMetric(NULL, NULL, LIM_LARGE, &icon);
@ -185,7 +188,7 @@ index 280b46c..ea2181d 100644
START_TEST(misc)
{
ULONG_PTR ctx_cookie;
@@ -220,6 +369,7 @@ START_TEST(misc)
@@ -220,6 +372,7 @@ START_TEST(misc)
return;
test_TaskDialogIndirect();