We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 1804 - Memory leak issue in src/video/x11/SDL_x11mouse.c file
Summary: Memory leak issue in src/video/x11/SDL_x11mouse.c file
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: 2.0.0
Hardware: x86 Linux
: P2 critical
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-04-16 01:33 UTC by Nitz
Modified: 2013-04-17 04:35 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nitz 2013-04-16 01:33:21 UTC
In SDL_x11mouse.c file there is function named 
static Cursor
X11_CreatePixmapCursor(SDL_Surface * surface, int hot_x, int hot_y)
{
  // Some code

  data_bits = SDL_calloc(1, surface->h * width_bytes);
  mask_bits = SDL_calloc(1, surface->h * width_bytes);
  if (!data_bits || !mask_bits) {
     SDL_OutOfMemory();
     return None;
  }
 
 // Some code

}

Here is the problem in if statement,
suppose if !data_bits is false and !mask_bits is true then,
data_bits will go out of scope and leaks the memory it points to.

Solution is that data_bits and mask_bits should be checked separately, not by using OR operator.
Comment 1 Sam Lantinga 2013-04-17 04:35:39 UTC
Fixed, thanks!
http://hg.libsdl.org/SDL/rev/82f17e656125