diff mbox

[PULL,03/13] loader: fix potential memory leak

Message ID ed2f3bc1fad37297468234add82f464b59b16830.1463573089.git.mjt@msgid.tls.msk.ru (mailing list archive)
State New, archived
Headers show

Commit Message

Michael Tokarev May 18, 2016, 12:05 p.m. UTC
From: Cao jin <caoj.fnst@cn.fujitsu.com>

Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 hw/core/loader.c | 6 ++++++
 1 file changed, 6 insertions(+)
diff mbox

Patch

diff --git a/hw/core/loader.c b/hw/core/loader.c
index c049957..53e0e41 100644
--- a/hw/core/loader.c
+++ b/hw/core/loader.c
@@ -914,10 +914,16 @@  int rom_add_file(const char *file, const char *fw_dir,
 err:
     if (fd != -1)
         close(fd);
+
     g_free(rom->data);
     g_free(rom->path);
     g_free(rom->name);
+    if (fw_dir) {
+        g_free(rom->fw_dir);
+        g_free(rom->fw_file);
+    }
     g_free(rom);
+
     return -1;
 }