diff options
author | Vinson Lee <[email protected]> | 2009-11-17 10:11:50 -0800 |
---|---|---|
committer | Vinson Lee <[email protected]> | 2009-11-17 10:11:50 -0800 |
commit | 041cd0e110d41b543a0fe9cc484ae8373642912b (patch) | |
tree | b6dce5f2f11e0c3309b332d8d02dd000dad24d5b /progs/util | |
parent | 33e93f42770e344edf1cd693a6c8115acd505a08 (diff) |
progs/util: Fix memory leak if LoadRGBImage fails.
Diffstat (limited to 'progs/util')
-rw-r--r-- | progs/util/readtex.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/progs/util/readtex.c b/progs/util/readtex.c index 4e22bed81af..ec27e20d681 100644 --- a/progs/util/readtex.c +++ b/progs/util/readtex.c @@ -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 ); |