"Reece Dunn" msclrhd@googlemail.com writes:
+static WCHAR *get_button_text(HWND hwnd, int *len) +{
- WCHAR *text;
- *len = GetWindowTextLengthW(hwnd);
- text = HeapAlloc(GetProcessHeap(), 0, (*len + 1) * sizeof(WCHAR));
- if (text)
GetWindowTextW(hwnd, text, *len + 1);
- return text;
+}
You shouldn't return the length you got from GetWindowTextLength, it can sometimes be larger than necessary. Use the actual length of the string you fetched.