diff mbox

elfload: Replace malloc with g_malloc

Message ID 1490091581-21912-1-git-send-email-maozy.fnst@cn.fujitsu.com
State New
Headers show

Commit Message

Mao Zhongyi March 21, 2017, 10:19 a.m. UTC
Signed-off-by: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>
---
 bsd-user/elfload.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Comments

Peter Maydell March 21, 2017, 10:50 a.m. UTC | #1
On 21 March 2017 at 10:19, Mao Zhongyi <maozy.fnst@cn.fujitsu.com> wrote:
> Signed-off-by: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>
> ---
>  bsd-user/elfload.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)

Thanks for this patch. How have you tested it? (You'd need to be
on a BSD host system to test). I ask because bsd-user is currently
not really maintained, and so I'm a bit reluctant to take cleanup
patches to code we aren't building and testing.

thanks
-- PMM
Mao Zhongyi March 21, 2017, 11:45 a.m. UTC | #2
On 03/21/2017 06:50 PM, Peter Maydell wrote:
> On 21 March 2017 at 10:19, Mao Zhongyi <maozy.fnst@cn.fujitsu.com> wrote:
>> Signed-off-by: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>
>> ---
>>  bsd-user/elfload.c | 12 ++++++------
>>  1 file changed, 6 insertions(+), 6 deletions(-)
>
> Thanks for this patch. How have you tested it? (You'd need to be
> on a BSD host system to test). I ask because bsd-user is currently
> not really maintained, and so I'm a bit reluctant to take cleanup
> patches to code we aren't building and testing.
>

Thanks for your quick response, due to lack of environment, I just have 
done make check, will install a bsd host as soon as possible. Is just 
starting qemu in bsd enough for test?

thanks
-- Mao
diff mbox

Patch

diff --git a/bsd-user/elfload.c b/bsd-user/elfload.c
index 41a1309..17dfaca 100644
--- a/bsd-user/elfload.c
+++ b/bsd-user/elfload.c
@@ -1064,22 +1064,22 @@  static void load_symbols(struct elfhdr *hdr, int fd)
 
  found:
     /* Now know where the strtab and symtab are.  Snarf them. */
-    s = malloc(sizeof(*s));
+    s = g_malloc(sizeof(*s));
     syms = malloc(symtab.sh_size);
     if (!syms) {
-        free(s);
+        g_free(s);
         return;
     }
     s->disas_strtab = strings = malloc(strtab.sh_size);
     if (!s->disas_strtab) {
-        free(s);
+        g_free(s);
         free(syms);
         return;
     }
 
     lseek(fd, symtab.sh_offset, SEEK_SET);
     if (read(fd, syms, symtab.sh_size) != symtab.sh_size) {
-        free(s);
+        g_free(s);
         free(syms);
         free(strings);
         return;
@@ -1115,7 +1115,7 @@  static void load_symbols(struct elfhdr *hdr, int fd)
         many symbols we managed to discard. */
     new_syms = realloc(syms, nsyms * sizeof(*syms));
     if (new_syms == NULL) {
-        free(s);
+        g_free(s);
         free(syms);
         free(strings);
         return;
@@ -1126,7 +1126,7 @@  static void load_symbols(struct elfhdr *hdr, int fd)
 
     lseek(fd, strtab.sh_offset, SEEK_SET);
     if (read(fd, strings, strtab.sh_size) != strtab.sh_size) {
-        free(s);
+        g_free(s);
         free(syms);
         free(strings);
         return;