Fixed bug 1804 - Memory leak issue in src/video/x11/SDL_x11mouse.c
Nitz 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.
This commit is contained in:
parent
eb97bff0bd
commit
a438cbd7fe
1 changed files with 7 additions and 1 deletions
|
@ -129,8 +129,14 @@ X11_CreatePixmapCursor(SDL_Surface * surface, int hot_x, int hot_y)
|
||||||
unsigned int width_bytes = ((surface->w + 7) & ~7) / 8;
|
unsigned int width_bytes = ((surface->w + 7) & ~7) / 8;
|
||||||
|
|
||||||
data_bits = SDL_calloc(1, surface->h * width_bytes);
|
data_bits = SDL_calloc(1, surface->h * width_bytes);
|
||||||
|
if (!data_bits) {
|
||||||
|
SDL_OutOfMemory();
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
mask_bits = SDL_calloc(1, surface->h * width_bytes);
|
mask_bits = SDL_calloc(1, surface->h * width_bytes);
|
||||||
if (!data_bits || !mask_bits) {
|
if (!mask_bits) {
|
||||||
|
SDL_free(data_bits);
|
||||||
SDL_OutOfMemory();
|
SDL_OutOfMemory();
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue