From 1e951605fb08fbd35a72c4a4e9e307909a5f6b70 Mon Sep 17 00:00:00 2001 From: Moshe Kaplan Date: Wed, 23 Jul 2014 13:58:17 -0400 Subject: [PATCH 1/2] Avoid leaking `iso` structures --- plugins/CDVDiso/src/libiso.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/CDVDiso/src/libiso.cpp b/plugins/CDVDiso/src/libiso.cpp index b32d5602a8..7275ece2a9 100644 --- a/plugins/CDVDiso/src/libiso.cpp +++ b/plugins/CDVDiso/src/libiso.cpp @@ -549,6 +549,7 @@ isoFile *isoOpen(const char *filename) if (iso->handle == NULL) { printf("Error loading %s\n", iso->filename); + free(iso); return NULL; } @@ -622,6 +623,7 @@ isoFile *isoCreate(const char *filename, int flags) iso->htable = _openfile(Zfile, O_WRONLY); if (iso->htable == NULL) { + free(iso); return NULL; } } @@ -629,6 +631,7 @@ isoFile *isoCreate(const char *filename, int flags) iso->handle = _openfile(iso->filename, O_WRONLY | O_CREAT); if (iso->handle == NULL) { + free(iso); printf("Error loading %s\n", iso->filename); return NULL; } @@ -1050,4 +1053,3 @@ void isoClose(isoFile *iso) free(iso); } - From e1dbdce91e4277d67588c691327ae0764cf43643 Mon Sep 17 00:00:00 2001 From: Moshe Kaplan Date: Tue, 29 Jul 2014 12:22:44 -0400 Subject: [PATCH 2/2] Update libiso.cpp Oops, accidentally caused a use-after-free --- plugins/CDVDiso/src/libiso.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/CDVDiso/src/libiso.cpp b/plugins/CDVDiso/src/libiso.cpp index 7275ece2a9..577a00a808 100644 --- a/plugins/CDVDiso/src/libiso.cpp +++ b/plugins/CDVDiso/src/libiso.cpp @@ -631,8 +631,8 @@ isoFile *isoCreate(const char *filename, int flags) iso->handle = _openfile(iso->filename, O_WRONLY | O_CREAT); if (iso->handle == NULL) { - free(iso); printf("Error loading %s\n", iso->filename); + free(iso); return NULL; } printf("isoCreate: %s ok\n", iso->filename);