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

Summary: Memory leak issue in src/video/x11/SDL_x11mouse.c file
Product: SDL Reporter: Nitz <nitin.j4>
Component: videoAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: critical    
Priority: P2    
Version: 2.0.0   
Hardware: x86   
OS: Linux   

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