windows: Call GetWindowText() with the correct parameters (thanks, Zebediah!)
authorRyan C. Gordon <icculus@icculus.org>
Wed, 26 Jun 2019 01:29:01 -0400
changeset 12906bd5a067d1fd8
parent 12905 a7eb3fe5cc41
child 12907 6a3b2cc9d66c
windows: Call GetWindowText() with the correct parameters (thanks, Zebediah!)

GetWindowText() wants you to tell it the size of the buffer--including the
terminating NULL char--but we weren't counting that last char, losing the
last char of the string in the process. This was only seen with the special
case of SDL_CreateWindowFrom() to use an existing native window, not
the usual SDL_CreateWindow() codepath.

Fixes Bugzilla #4696.
src/video/windows/SDL_windowswindow.c
     1.1 --- a/src/video/windows/SDL_windowswindow.c	Tue Jun 25 11:47:02 2019 +0300
     1.2 +++ b/src/video/windows/SDL_windowswindow.c	Wed Jun 26 01:29:01 2019 -0400
     1.3 @@ -386,7 +386,7 @@
     1.4      titleLen = GetWindowTextLength(hwnd);
     1.5      title = SDL_small_alloc(TCHAR, titleLen + 1, &isstack);
     1.6      if (title) {
     1.7 -        titleLen = GetWindowText(hwnd, title, titleLen);
     1.8 +        titleLen = GetWindowText(hwnd, title, titleLen + 1);
     1.9      } else {
    1.10          titleLen = 0;
    1.11      }