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 100428546f8015052
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
     1.1 --- a/src/events/SDL_dropevents.c	Thu Jan 07 12:01:51 2016 -0800
     1.2 +++ b/src/events/SDL_dropevents.c	Thu Jan 07 16:01:24 2016 -0500
     1.3 @@ -43,7 +43,11 @@
     1.4          if (need_begin) {
     1.5              SDL_zero(event);
     1.6              event.type = SDL_DROPBEGIN;
     1.7 -            event.drop.windowID = window->id;
     1.8 +
     1.9 +            if (window) {
    1.10 +                event.drop.windowID = window->id;
    1.11 +            }
    1.12 +
    1.13              posted = (SDL_PushEvent(&event) > 0);
    1.14              if (!posted) {
    1.15                  return 0;