Fixed NULL dereference on drop events with no window associated.

(such as when dropping a file onto an app's icon to launch.)

This bug caught by Clang's static analyzer.
This commit is contained in:
Ryan C. Gordon 2016-01-07 16:01:24 -05:00
parent 1c4c3f505f
commit 73680ab374
1 changed files with 5 additions and 1 deletions

View File

@ -43,7 +43,11 @@ SDL_SendDrop(SDL_Window *window, const SDL_EventType evtype, const char *data)
if (need_begin) { if (need_begin) {
SDL_zero(event); SDL_zero(event);
event.type = SDL_DROPBEGIN; event.type = SDL_DROPBEGIN;
if (window) {
event.drop.windowID = window->id; event.drop.windowID = window->id;
}
posted = (SDL_PushEvent(&event) > 0); posted = (SDL_PushEvent(&event) > 0);
if (!posted) { if (!posted) {
return 0; return 0;