mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-24 08:50:13 +01:00
progs/util: Fix memory leak if LoadRGBImage fails.
This commit is contained in:
parent
33e93f4277
commit
041cd0e110
1 changed files with 4 additions and 1 deletions
|
|
@ -357,6 +357,7 @@ GLubyte *LoadRGBImage( const char *imageFile, GLint *width, GLint *height,
|
|||
fprintf(stderr,
|
||||
"Error in LoadRGBImage %d-component images not implemented\n",
|
||||
image->components );
|
||||
FreeImage(image);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -365,8 +366,10 @@ GLubyte *LoadRGBImage( const char *imageFile, GLint *width, GLint *height,
|
|||
|
||||
bytes = image->sizeX * image->sizeY * image->components;
|
||||
buffer = (GLubyte *) malloc(bytes);
|
||||
if (!buffer)
|
||||
if (!buffer) {
|
||||
FreeImage(image);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memcpy( (void *) buffer, (void *) image->data, bytes );
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue