Nikolay Sivov : comctl32/tooltips: Allow NULL hinst value when fetching text from resources.
Alexandre Julliard
julliard at wine.codeweavers.com
Tue Mar 24 10:00:44 CDT 2015
Module: wine
Branch: master
Commit: 9d0ebc13ac7e0dad17ff104c38f8ebd7b9326aa6
URL: http://source.winehq.org/git/wine.git/?a=commit;h=9d0ebc13ac7e0dad17ff104c38f8ebd7b9326aa6
Author: Nikolay Sivov <nsivov at codeweavers.com>
Date: Tue Mar 24 00:10:06 2015 +0300
comctl32/tooltips: Allow NULL hinst value when fetching text from resources.
---
dlls/comctl32/tests/tooltips.c | 26 ++++++++++++++++++++++++++
dlls/comctl32/tooltips.c | 6 +++---
2 files changed, 29 insertions(+), 3 deletions(-)
diff --git a/dlls/comctl32/tests/tooltips.c b/dlls/comctl32/tests/tooltips.c
index 271009d..a07a054 100644
--- a/dlls/comctl32/tests/tooltips.c
+++ b/dlls/comctl32/tests/tooltips.c
@@ -20,6 +20,8 @@
#include <windows.h>
#include <commctrl.h>
+#include "resources.h"
+
#include "wine/test.h"
#define expect(expected, got) ok(got == expected, "Expected %d, got %d\n", expected, got)
@@ -326,6 +328,30 @@ static void test_gettext(void)
SendMessageA(hwnd, TTM_GETTOOLINFOA, 0, (LPARAM)&toolinfoA);
ok(toolinfoA.lpszText == NULL,
"expected NULL, got %p\n", toolinfoA.lpszText);
+
+ /* NULL hinst, valid resource id for text */
+ toolinfoA.cbSize = sizeof(TTTOOLINFOA);
+ toolinfoA.hwnd = NULL;
+ toolinfoA.hinst = NULL;
+ toolinfoA.uFlags = 0;
+ toolinfoA.uId = 0x1233ABCD;
+ toolinfoA.lpszText = MAKEINTRESOURCEA(IDS_TBADD1);
+ toolinfoA.lParam = 0xdeadbeef;
+ GetClientRect(hwnd, &toolinfoA.rect);
+ r = SendMessageA(hwnd, TTM_ADDTOOLA, 0, (LPARAM)&toolinfoA);
+ ok(r, "failed to add a tool\n");
+
+ toolinfoA.hwnd = NULL;
+ toolinfoA.uId = 0x1233ABCD;
+ toolinfoA.lpszText = bufA;
+ SendMessageA(hwnd, TTM_GETTEXTA, 0, (LPARAM)&toolinfoA);
+ ok(strcmp(toolinfoA.lpszText, "abc") == 0, "lpszText should be an empty string\n");
+
+ toolinfoA.hinst = (HINSTANCE)0xdeadbee;
+ SendMessageA(hwnd, TTM_GETTOOLINFOA, 0, (LPARAM)&toolinfoA);
+ ok(toolinfoA.hinst == NULL, "expected NULL, got %p\n", toolinfoA.hinst);
+
+ SendMessageA(hwnd, TTM_DELTOOLA, 0, (LPARAM)&toolinfoA);
}
else
{
diff --git a/dlls/comctl32/tooltips.c b/dlls/comctl32/tooltips.c
index 7564c3f..5423ca5 100644
--- a/dlls/comctl32/tooltips.c
+++ b/dlls/comctl32/tooltips.c
@@ -484,12 +484,12 @@ TOOLTIPS_GetTipText (const TOOLTIPS_INFO *infoPtr, INT nTool, WCHAR *buffer)
{
TTTOOL_INFO *toolPtr = &infoPtr->tools[nTool];
- if (IS_INTRESOURCE(toolPtr->lpszText) && toolPtr->hinst) {
+ if (IS_INTRESOURCE(toolPtr->lpszText)) {
/* load a resource */
TRACE("load res string %p %x\n",
toolPtr->hinst, LOWORD(toolPtr->lpszText));
- LoadStringW (toolPtr->hinst, LOWORD(toolPtr->lpszText),
- buffer, INFOTIPSIZE);
+ if (!LoadStringW (toolPtr->hinst, LOWORD(toolPtr->lpszText), buffer, INFOTIPSIZE))
+ buffer[0] = '\0';
}
else if (toolPtr->lpszText) {
if (toolPtr->lpszText == LPSTR_TEXTCALLBACKW) {
More information about the wine-cvs
mailing list