Hi, comments inline.
On 2017-05-15 18:05, gadamopou...@svn.reactos.org wrote:
--- trunk/reactos/dll/win32/uxtheme/nonclient.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/uxtheme/nonclient.c [iso-8859-1] Mon May 15 16:05:14 2017 @@ -100,16 +100,7 @@ return hIcon; } -WCHAR *UserGetWindowCaption(HWND hwnd) -{ - INT len = 512; - WCHAR *text; - text = (WCHAR*)HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); - if (text) InternalGetWindowText(hwnd, text, len); - return text; -} - -HRESULT WINAPI ThemeDrawCaptionText(PDRAW_CONTEXT pcontext, RECT* pRect, int iPartId, int iStateId, LPCWSTR pszText) +HRESULT WINAPI ThemeDrawCaptionText(PDRAW_CONTEXT pcontext, RECT* pRect, int iPartId, int iStateId) { HRESULT hr; HFONT hFont = NULL; @@ -117,6 +108,25 @@ LOGFONTW logfont; COLORREF textColor; COLORREF oldTextColor; + + WCHAR buffer[50]; + WCHAR *pszText = buffer; + INT len; + + len = InternalGetWindowText(pcontext->hWnd, NULL, 0); + if (!len) + return S_OK; + + len++; /* From now on this is the size of the buffer so include the null */ + + if (len > 50)
_countof(buffer), or ARRAYSIZE, or whatever people use these days.
+ { + pszText = (WCHAR*)HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
Unnecessary cast.
+ if (!pszText) + return E_FAIL;
Ewwww. Worst error code. Thanks. -Thomas _______________________________________________ Ros-dev mailing list Ros-dev@reactos.org http://www.reactos.org/mailman/listinfo/ros-dev