From c26ba0d34424e9526a46bea23e9753d59a6be55c Mon Sep 17 00:00:00 2001 From: that Date: Fri, 13 Feb 2015 01:09:55 +0100 Subject: minuitwrp: fix file descriptor leak in open_png This fixes missing images after reloading the material theme 3 times. Change-Id: I9af2a76b16e465fd2218e5f479c36a294590fa62 --- minuitwrp/resources.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/minuitwrp/resources.c b/minuitwrp/resources.c index 680bf56a3..3e3375d11 100644 --- a/minuitwrp/resources.c +++ b/minuitwrp/resources.c @@ -54,7 +54,7 @@ static GGLSurface* malloc_surface(size_t data_size) { } static int open_png(const char* name, png_structp* png_ptr, png_infop* info_ptr, - png_uint_32* width, png_uint_32* height, png_byte* channels) { + png_uint_32* width, png_uint_32* height, png_byte* channels, FILE** fpp) { char resPath[256]; unsigned char header[8]; int result = 0; @@ -131,6 +131,7 @@ static int open_png(const char* name, png_structp* png_ptr, png_infop* info_ptr, png_set_palette_to_rgb(png_ptr); } + *fpp = fp; return result; exit: @@ -219,10 +220,11 @@ int res_create_surface_png(const char* name, gr_surface* pSurface) { png_infop info_ptr = NULL; png_uint_32 width, height; png_byte channels; + FILE* fp; *pSurface = NULL; - result = open_png(name, &png_ptr, &info_ptr, &width, &height, &channels); + result = open_png(name, &png_ptr, &info_ptr, &width, &height, &channels, &fp); if (result < 0) return result; surface = init_display_surface(width, height); @@ -247,6 +249,7 @@ int res_create_surface_png(const char* name, gr_surface* pSurface) { *pSurface = (gr_surface) surface; exit: + fclose(fp); png_destroy_read_struct(&png_ptr, &info_ptr, NULL); if (result < 0 && surface != NULL) free(surface); return result; -- cgit v1.2.3