[Commits] SDL: haiku: Fixed SDL_SetClipboardText() allocating too much mem...

libsdl.org revision control commits-owner at libsdl.org
Sat May 27 14:35:20 PDT 2017


details:   https://hg.libsdl.org/SDL/rev/d0e35a9ba1f6
changeset: 11039:d0e35a9ba1f6
user:      Philipp Wiesemann <philipp.wiesemann at arcor.de>
date:      Sat May 27 23:30:21 2017 +0200
description:
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().

diffstat:

 src/video/haiku/SDL_bclipboard.cc |  4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diffs (14 lines):

diff -r b2883845e32c -r d0e35a9ba1f6 src/video/haiku/SDL_bclipboard.cc
--- a/src/video/haiku/SDL_bclipboard.cc	Sat May 27 23:30:07 2017 +0200
+++ b/src/video/haiku/SDL_bclipboard.cc	Sat May 27 23:30:21 2017 +0200
@@ -69,8 +69,8 @@
 		result = SDL_strdup("");
 	} else {
 		/* Copy the data and pass on to SDL */
-		result = (char*)SDL_calloc(1, sizeof(char*)*length);
-		SDL_strlcpy(result, text, length);
+		result = (char *)SDL_malloc((length + 1) * sizeof(char));
+		SDL_strlcpy(result, text, length + 1);
 	}
 	
 	return result;


More information about the commits mailing list