Fixed NULL dereference on drop events with no window associated.
authorRyan C. Gordon <icculus@icculus.org>
Thu, 07 Jan 2016 16:01:24 -0500
changeset 10042 8546f8015052
parent 10041 f6c9f42a54d6
child 10043 24e8d042e532
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.
src/events/SDL_dropevents.c
--- a/src/events/SDL_dropevents.c	Thu Jan 07 12:01:51 2016 -0800
+++ b/src/events/SDL_dropevents.c	Thu Jan 07 16:01:24 2016 -0500
@@ -43,7 +43,11 @@
         if (need_begin) {
             SDL_zero(event);
             event.type = SDL_DROPBEGIN;
-            event.drop.windowID = window->id;
+
+            if (window) {
+                event.drop.windowID = window->id;
+            }
+
             posted = (SDL_PushEvent(&event) > 0);
             if (!posted) {
                 return 0;