diff options
Diffstat (limited to 'plugins/MirLua/Modules')
-rwxr-xr-x[-rw-r--r--] | plugins/MirLua/Modules/WinAPI/src/winapi.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/plugins/MirLua/Modules/WinAPI/src/winapi.cpp b/plugins/MirLua/Modules/WinAPI/src/winapi.cpp index 2fe8f9f3b3..8ef0708d7d 100644..100755 --- a/plugins/MirLua/Modules/WinAPI/src/winapi.cpp +++ b/plugins/MirLua/Modules/WinAPI/src/winapi.cpp @@ -360,14 +360,15 @@ static int global_FindWindowEx(lua_State *L) static int global_GetWindowText(lua_State *L)
{
const HWND hwnd = (HWND)luaM_checkhwnd(L, 1);
-
- wchar_t buf[2048] = { 0 };
- int res = GetWindowTextW(hwnd, buf, sizeof(buf));
+ int buf_size = GetWindowTextLengthW(hwnd);
+ wchar_t *buf = (wchar_t*)mir_alloc((buf_size + 1) * sizeof(wchar_t));
+ int res = GetWindowTextW(hwnd, buf, (buf_size + 1) * sizeof(wchar_t));
if (res > 0 || GetLastError() == ERROR_SUCCESS)
lua_pushstring(L, T2Utf(buf));
else
lua_pushnil(L);
+ mir_free(buf);
return 1;
}
|