aboutsummaryrefslogtreecommitdiffstats
path: root/c_src/sdl_clipboard.c
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2014-04-04 20:13:10 +0200
committerLoïc Hoguin <[email protected]>2014-04-04 20:13:10 +0200
commitbe44046850adf018e648752571247115638df75b (patch)
tree05987991abd2472db7f666334eeee64a885565a5 /c_src/sdl_clipboard.c
parent0633a7b6f0b1eb20043b71cc59847ca8648732f0 (diff)
downloadesdl2-be44046850adf018e648752571247115638df75b.tar.gz
esdl2-be44046850adf018e648752571247115638df75b.tar.bz2
esdl2-be44046850adf018e648752571247115638df75b.zip
Fix potential memory leaks and other small improvements
Diffstat (limited to 'c_src/sdl_clipboard.c')
-rw-r--r--c_src/sdl_clipboard.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/c_src/sdl_clipboard.c b/c_src/sdl_clipboard.c
index 14d1a3e..2ecc485 100644
--- a/c_src/sdl_clipboard.c
+++ b/c_src/sdl_clipboard.c
@@ -53,7 +53,11 @@ NIF_FUNCTION(set_clipboard_text)
BADARG_IF(!enif_get_list_length(env, argv[0], &len));
text = (char*)enif_alloc(len + 1);
- BADARG_IF(!enif_get_string(env, argv[0], text, len + 1, ERL_NIF_LATIN1));
+
+ if (!enif_get_string(env, argv[0], text, len + 1, ERL_NIF_LATIN1)) {
+ enif_free(text);
+ return enif_make_badarg(env);
+ }
ret = SDL_SetClipboardText(text);