From d555656a415195ed3db121d9e0b851f49471fd92 Mon Sep 17 00:00:00 2001 From: Moshe Kaplan Date: Wed, 30 Jul 2014 22:52:34 -0400 Subject: [PATCH] Cleanup leaking memory and filehandles --- plugins/CDVDpeops/libiso.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plugins/CDVDpeops/libiso.c b/plugins/CDVDpeops/libiso.c index 205eec2c9b..9da815378f 100644 --- a/plugins/CDVDpeops/libiso.c +++ b/plugins/CDVDpeops/libiso.c @@ -220,6 +220,7 @@ int _isoReadZtable(isoFile *iso) { size = (int)_tellfile(handle); iso->Ztable = (char*)malloc(size); if (iso->Ztable == NULL) { + _closefile(handle); return -1; } @@ -251,6 +252,7 @@ int _isoReadZ2table(isoFile *iso) { size = (int)_tellfile(handle); Ztable = (u32*)malloc(size); if (Ztable == NULL) { + _closefile(handle); return -1; } @@ -260,6 +262,7 @@ int _isoReadZ2table(isoFile *iso) { iso->Ztable = (char*)malloc(iso->blocks*8); if (iso->Ztable == NULL) { + free(Ztable); return -1; } @@ -390,6 +393,7 @@ isoFile *isoOpen(const char *filename) { iso->handle = _openfile(iso->filename, O_RDONLY); if (iso->handle == NULL) { printf("Error loading %s\n", iso->filename); + free(iso); return NULL; } @@ -459,6 +463,7 @@ isoFile *isoCreate(const char *filename, int flags) { sprintf(Zfile, "%s.table", iso->filename); iso->htable = _openfile(Zfile, O_WRONLY); if (iso->htable == NULL) { + free(iso); return NULL; } } @@ -466,6 +471,7 @@ isoFile *isoCreate(const char *filename, int flags) { iso->handle = _openfile(iso->filename, O_WRONLY); if (iso->handle == NULL) { printf("Error loading %s\n", iso->filename); + free(iso); return NULL; } printf("isoCreate: %s ok\n", iso->filename);