haiku: Fixed SDL_SetClipboardText() allocating too much memory and cutting text.
authorPhilipp Wiesemann <philipp.wiesemann@arcor.de>
Sat, 27 May 2017 23:30:21 +0200
changeset 11039d0e35a9ba1f6
parent 11038 b2883845e32c
child 11040 8ff2f9651a0e
haiku: Fixed SDL_SetClipboardText() allocating too much memory and cutting text.

It allocated pointers instead of chars and passed a wrong size to SDL_strlcpy().
src/video/haiku/SDL_bclipboard.cc
     1.1 --- a/src/video/haiku/SDL_bclipboard.cc	Sat May 27 23:30:07 2017 +0200
     1.2 +++ b/src/video/haiku/SDL_bclipboard.cc	Sat May 27 23:30:21 2017 +0200
     1.3 @@ -69,8 +69,8 @@
     1.4  		result = SDL_strdup("");
     1.5  	} else {
     1.6  		/* Copy the data and pass on to SDL */
     1.7 -		result = (char*)SDL_calloc(1, sizeof(char*)*length);
     1.8 -		SDL_strlcpy(result, text, length);
     1.9 +		result = (char *)SDL_malloc((length + 1) * sizeof(char));
    1.10 +		SDL_strlcpy(result, text, length + 1);
    1.11  	}
    1.12  	
    1.13  	return result;