8c6b1ac71e
Also include some minor fixes for gcc 5.1.1 Signed-off-by: Peter Jones <pjones@redhat.com>
49 lines
1.3 KiB
Diff
49 lines
1.3 KiB
Diff
From 95a8c9182bc8ab25cbd62424f28a32432f823698 Mon Sep 17 00:00:00 2001
|
|
From: Vladimir Serbinenko <phcoder@gmail.com>
|
|
Date: Sat, 24 Jan 2015 20:50:35 +0100
|
|
Subject: [PATCH 184/506] commands/fileXX: Fix memory leak.
|
|
|
|
Found by: Coverity Scan.
|
|
---
|
|
grub-core/commands/fileXX.c | 9 ++++++---
|
|
1 file changed, 6 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/grub-core/commands/fileXX.c b/grub-core/commands/fileXX.c
|
|
index 58e1094..7743f3e 100644
|
|
--- a/grub-core/commands/fileXX.c
|
|
+++ b/grub-core/commands/fileXX.c
|
|
@@ -40,10 +40,10 @@ grub_file_check_netbsdXX (grub_elf_t elf)
|
|
return 0;
|
|
|
|
if (grub_file_seek (elf->file, elf->ehdr.ehdrXX.e_shoff) == (grub_off_t) -1)
|
|
- return 0;
|
|
+ goto fail;
|
|
|
|
if (grub_file_read (elf->file, s0, shsize) != (grub_ssize_t) shsize)
|
|
- return 0;
|
|
+ goto fail;
|
|
|
|
s = (Elf_Shdr *) ((char *) s0 + elf->ehdr.ehdrXX.e_shstrndx * shentsize);
|
|
stroff = s->sh_offset;
|
|
@@ -59,13 +59,16 @@ grub_file_check_netbsdXX (grub_elf_t elf)
|
|
if (grub_file_read (elf->file, name, sizeof (name)) != (grub_ssize_t) sizeof (name))
|
|
{
|
|
if (grub_errno)
|
|
- return grub_errno;
|
|
+ goto fail;
|
|
continue;
|
|
}
|
|
if (grub_memcmp (name, ".note.netbsd.ident",
|
|
sizeof(".note.netbsd.ident")) != 0)
|
|
continue;
|
|
+ grub_free (s0);
|
|
return 1;
|
|
}
|
|
+ fail:
|
|
+ grub_free (s0);
|
|
return 0;
|
|
}
|
|
--
|
|
2.4.3
|
|
|