Skip to content

Commit

Permalink
Fixed bug 3976 - SDL drivers may leak driverdata memory due to ignori…
Browse files Browse the repository at this point in the history
…ng return value of SDL_AddDisplayMode

C Snover

SDL_AddDisplayMode returns an SDL_bool corresponding to whether or not the given display mode was added or not. It will return SDL_FALSE if a matching display mode already exists in the display's list of display modes, which causes ownership of the mode driverdata to remain with the caller. Some video drivers ignore the return value of SDL_AddDisplayMode, so leak the driverdata memory when SDL_AddDisplayMode returns SDL_FALSE.
  • Loading branch information
slouken committed Nov 22, 2017
1 parent 688bc28 commit 1c0c903
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/video/cocoa/SDL_cocoamodes.m
Expand Up @@ -354,7 +354,9 @@
SDL_DisplayMode mode;
if (GetDisplayMode(_this, moderef, link, &mode)) {
CGDisplayModeRetain(moderef);
SDL_AddDisplayMode(display, &mode);
if (!SDL_AddDisplayMode(display, &mode)) {
SDL_free(mode.driverdata);
}
}
}

Expand Down

0 comments on commit 1c0c903

Please sign in to comment.