From 15ecf3ddae26144cb68ec8581dd3c402df11cab3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=A1vio=20J=2E=20Saraiva?= Date: Sat, 9 Mar 2024 19:16:05 +0000 Subject: [PATCH] Fix resource leaks in ppc32_load_raw_image fixes #113 --- stable/ppc32.c | 2 ++ unstable/ppc32.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/stable/ppc32.c b/stable/ppc32.c index c5af88b25..bc9eabd83 100644 --- a/stable/ppc32.c +++ b/stable/ppc32.c @@ -492,6 +492,7 @@ int ppc32_load_raw_image(cpu_ppc_t *cpu,char *filename,m_uint32_t vaddr) if (fstat(fileno(bfd),&file_info) == -1) { perror("stat"); + fclose(bfd); return(-1); } @@ -507,6 +508,7 @@ int ppc32_load_raw_image(cpu_ppc_t *cpu,char *filename,m_uint32_t vaddr) if (!haddr) { fprintf(stderr,"load_raw_image: invalid load address 0x%8.8x\n", vaddr); + fclose(bfd); return(-1); } diff --git a/unstable/ppc32.c b/unstable/ppc32.c index ed24f7d97..e2519b0e7 100644 --- a/unstable/ppc32.c +++ b/unstable/ppc32.c @@ -489,6 +489,7 @@ int ppc32_load_raw_image(cpu_ppc_t *cpu,char *filename,m_uint32_t vaddr) if (fstat(fileno(bfd),&file_info) == -1) { perror("stat"); + fclose(bfd); return(-1); } @@ -504,6 +505,7 @@ int ppc32_load_raw_image(cpu_ppc_t *cpu,char *filename,m_uint32_t vaddr) if (!haddr) { fprintf(stderr,"load_raw_image: invalid load address 0x%8.8x\n", vaddr); + fclose(bfd); return(-1); }