Browse code

bugfix: fix memory leak when getting the clipboard text

Dario Rodriguez authored on 02/06/2021 05:33:05
Showing 1 changed files
... ...
@@ -984,8 +984,11 @@ fprintf(stderr,"SDL_KEYDOWN: BACKSPACE%s\n",(event==&fakeevent)?" (fake)":"");
984 984
                         return(-1); /* error obtaining position */
985 985
                 if(re->selactive)
986 986
                         re_sel_toggle(re);
987
-                if(SDL_HasClipboardText())
988
-                        re_selectbuf_replace(re,SDL_GetClipboardText());
987
+                if(SDL_HasClipboardText()) {
988
+                        char *ptr;
989
+                        re_selectbuf_replace(re,(ptr=SDL_GetClipboardText()));
990
+                        SDL_free(ptr),ptr=NULL;
991
+                }
989 992
                 if(SDL_HasClipboardText()) {
990 993
                         char *ptr;
991 994
                         re_selectbuf_replace(re,(ptr=SDL_GetClipboardText()));