From 71af69ab3dab6921559540f7d5328e8a5e1632ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=A1vio=20J=2E=20Saraiva?= Date: Sat, 9 Mar 2024 17:07:39 +0000 Subject: [PATCH] Fix descriptor leaks in mips64_load_raw_image fixes #112 --- stable/mips64.c | 2 ++ unstable/mips64.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/stable/mips64.c b/stable/mips64.c index 39ec2a76e..6ea30f366 100644 --- a/stable/mips64.c +++ b/stable/mips64.c @@ -865,6 +865,7 @@ int mips64_load_raw_image(cpu_mips_t *cpu,char *filename,m_uint64_t vaddr) if (fstat(fileno(bfd),&file_info) == -1) { perror("stat"); + fclose(bfd); return(-1); } @@ -880,6 +881,7 @@ int mips64_load_raw_image(cpu_mips_t *cpu,char *filename,m_uint64_t vaddr) if (!haddr) { fprintf(stderr,"load_raw_image: invalid load address 0x%llx\n", vaddr); + fclose(bfd); return(-1); } diff --git a/unstable/mips64.c b/unstable/mips64.c index bde636b0d..e301abcd6 100644 --- a/unstable/mips64.c +++ b/unstable/mips64.c @@ -948,6 +948,7 @@ int mips64_load_raw_image(cpu_mips_t *cpu,char *filename,m_uint64_t vaddr) if (fstat(fileno(bfd),&file_info) == -1) { perror("stat"); + fclose(bfd); return(-1); } @@ -963,6 +964,7 @@ int mips64_load_raw_image(cpu_mips_t *cpu,char *filename,m_uint64_t vaddr) if (!haddr) { fprintf(stderr,"load_raw_image: invalid load address 0x%llx\n", vaddr); + fclose(bfd); return(-1); }