Fixed potential double-free in mouse cleanup code
authorSam Lantinga <slouken@libsdl.org>
Tue, 18 Jun 2019 13:41:38 -0700
changeset 12882d629b4244b87
parent 12881 1e71522317eb
child 12883 72ab279ffcaa
Fixed potential double-free in mouse cleanup code
src/video/cocoa/SDL_cocoamouse.m
     1.1 --- a/src/video/cocoa/SDL_cocoamouse.m	Tue Jun 18 10:08:19 2019 -0700
     1.2 +++ b/src/video/cocoa/SDL_cocoamouse.m	Tue Jun 18 13:41:38 2019 -0700
     1.3 @@ -348,10 +348,9 @@
     1.4  
     1.5      Cocoa_InitMouseEventTap(mouse->driverdata);
     1.6  
     1.7 -    SDL_MouseData *driverdata = (SDL_MouseData*)mouse->driverdata;
     1.8      const NSPoint location =  [NSEvent mouseLocation];
     1.9 -    driverdata->lastMoveX = location.x;
    1.10 -    driverdata->lastMoveY = location.y;
    1.11 +    mouse->driverdata->lastMoveX = location.x;
    1.12 +    mouse->driverdata->lastMoveY = location.y;
    1.13  }
    1.14  
    1.15  void
    1.16 @@ -482,9 +481,10 @@
    1.17      if (mouse) {
    1.18          if (mouse->driverdata) {
    1.19              Cocoa_QuitMouseEventTap(((SDL_MouseData*)mouse->driverdata));
    1.20 +
    1.21 +            SDL_free(mouse->driverdata);
    1.22 +            mouse->driverdata = NULL;
    1.23          }
    1.24 -
    1.25 -        SDL_free(mouse->driverdata);
    1.26      }
    1.27  }
    1.28