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.
Sam Lantinga 2019-07-03 02:37:15 -07:00
parent b46c771994
commit 3fc447dfc9
1 changed files with 4 additions and 3 deletions

View File

@ -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);
}
}