From 041cd0e110d41b543a0fe9cc484ae8373642912b Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Tue, 17 Nov 2009 10:11:50 -0800 Subject: progs/util: Fix memory leak if LoadRGBImage fails. --- progs/util/readtex.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'progs') diff --git a/progs/util/readtex.c b/progs/util/readtex.c index 4e22bed81a..ec27e20d68 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 ); -- cgit v1.2.3