Browse Source

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().
Philipp Wiesemann 8 years ago
parent
commit
604a4b1b30
1 changed files with 2 additions and 2 deletions
  1. 2 2
      src/video/haiku/SDL_bclipboard.cc

+ 2 - 2
src/video/haiku/SDL_bclipboard.cc

@@ -69,8 +69,8 @@ char *BE_GetClipboardText(_THIS) {
 		result = SDL_strdup("");
 		result = SDL_strdup("");
 	} else {
 	} else {
 		/* Copy the data and pass on to SDL */
 		/* 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;
 	return result;