From 3fc447dfc9162c302ad8c953d1e08b17fc879bf7 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 3 Jul 2019 02:37:15 -0700 Subject: [PATCH] Fixed bug 4708 - testdropfile: double-free Juha Niemim?ki SDLTest_CommonEvent seems to free the file name so testdropfile prints some garbage to console and crashes when freeing the name again. --- test/testdropfile.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/testdropfile.c b/test/testdropfile.c index c0cc7a5d1..97ab872a2 100644 --- a/test/testdropfile.c +++ b/test/testdropfile.c @@ -75,8 +75,6 @@ main(int argc, char *argv[]) while (!done) { /* Check for events */ while (SDL_PollEvent(&event)) { - SDLTest_CommonEvent(state, &event, &done); - if (event.type == SDL_DROPBEGIN) { SDL_Log("Drop beginning on window %u", (unsigned int) event.drop.windowID); } else if (event.type == SDL_DROPCOMPLETE) { @@ -85,8 +83,11 @@ main(int argc, char *argv[]) const char *typestr = (event.type == SDL_DROPFILE) ? "File" : "Text"; char *dropped_filedir = event.drop.file; SDL_Log("%s dropped on window %u: %s", typestr, (unsigned int) event.drop.windowID, dropped_filedir); - SDL_free(dropped_filedir); + /* Normally you'd have to do this, but this is freed in SDLTest_CommonEvent() */ + /*SDL_free(dropped_filedir);*/ } + + SDLTest_CommonEvent(state, &event, &done); } }