Module: Mesa
Branch: master
Commit: 7eaf33ad0349e39dd6611b0b27aa44687e8c3014
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=7eaf33ad0349e39dd6611b0b27aa44687e8c3014

Author: Vinson Lee <[email protected]>
Date:   Wed Feb 17 01:57:14 2010 -0800

progs/redbook: Fix memory leaks on error paths.

---

 progs/redbook/convolution.c |    1 +
 progs/redbook/histogram.c   |    1 +
 progs/redbook/minmax.c      |    1 +
 3 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/progs/redbook/convolution.c b/progs/redbook/convolution.c
index 0543379..0898ef2 100644
--- a/progs/redbook/convolution.c
+++ b/progs/redbook/convolution.c
@@ -97,6 +97,7 @@ readImage( const char* filename, GLsizei* width, GLsizei 
*height )
     pixels = (GLubyte *) malloc( n * sizeof( GLubyte ));
     if ( !pixels ) {
        fprintf( stderr, "Unable to malloc() bytes for pixels\n" );
+       fclose( infile );
        return NULL;
     }
 
diff --git a/progs/redbook/histogram.c b/progs/redbook/histogram.c
index de1e59e..70a5282 100644
--- a/progs/redbook/histogram.c
+++ b/progs/redbook/histogram.c
@@ -102,6 +102,7 @@ readImage( const char* filename, GLsizei* width, GLsizei 
*height )
     pixels = (GLubyte *) malloc( n * sizeof( GLubyte ));
     if ( !pixels ) {
        fprintf( stderr, "Unable to malloc() bytes for pixels\n" );
+       fclose( infile );
        return NULL;
     }
 
diff --git a/progs/redbook/minmax.c b/progs/redbook/minmax.c
index da5b875..8281800 100644
--- a/progs/redbook/minmax.c
+++ b/progs/redbook/minmax.c
@@ -97,6 +97,7 @@ readImage( const char* filename, GLsizei* width, GLsizei 
*height )
     pixels = (GLubyte *) malloc( n * sizeof( GLubyte ));
     if ( !pixels ) {
        fprintf( stderr, "Unable to malloc() bytes for pixels\n" );
+       fclose( infile );
        return NULL;
     }
 

_______________________________________________
mesa-commit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to