[PATCH 02/12] gui: Fix resource leak

Alexander Shiyan shc_work at mail.ru
Sat Apr 12 01:10:55 PDT 2014


Signed-off-by: Alexander Shiyan <shc_work at mail.ru>
---
 lib/gui/picopng.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/gui/picopng.c b/lib/gui/picopng.c
index 77cd81c..e740b1c 100644
--- a/lib/gui/picopng.c
+++ b/lib/gui/picopng.c
@@ -761,9 +761,12 @@ int main(int argc, char **argv)
 	infp = fopen(fname, "rb");
 	if (!infp) {
 		perror("fopen");
+		free(inbuf);
 		return 1;
 	} else if (fread(inbuf, 1, insize, infp) != insize) {
 		perror("fread");
+		free(inbuf);
+		fclose(infp);
 		return 1;
 	}
 	fclose(infp);
@@ -793,6 +796,7 @@ int main(int argc, char **argv)
 		return 1;
 	} else if (fwrite(info->image->data, 1, outsize, outfp) != outsize) {
 		perror("fwrite");
+		fclose(outfp);
 		return 1;
 	}
 	fclose(outfp);
-- 
1.8.3.2




More information about the barebox mailing list