Skip to content
Snippets Groups Projects
Commit 8ce3c44c authored by Markus Armbruster's avatar Markus Armbruster Committed by Michael S. Tsirkin
Browse files

loader: g_realloc(p, 0) frees and returns NULL, simplify


Once upon a time, it was decided that qemu_realloc(ptr, 0) should
abort.  Switching to glib retired that bright idea.  A bit of code
that was added to cope with it (commit 3e372cf8) is still around.  Bury
it.

See also commit 6528499f.

Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
parent ed911435
No related branches found
No related tags found
No related merge requests found
......@@ -147,18 +147,13 @@ static int glue(load_symbols, SZ)(struct elfhdr *ehdr, int fd, int must_swab,
}
i++;
}
if (nsyms) {
syms = g_realloc(syms, nsyms * sizeof(*syms));
syms = g_realloc(syms, nsyms * sizeof(*syms));
qsort(syms, nsyms, sizeof(*syms), glue(symcmp, SZ));
for (i = 0; i < nsyms - 1; i++) {
if (syms[i].st_size == 0) {
syms[i].st_size = syms[i + 1].st_value - syms[i].st_value;
}
qsort(syms, nsyms, sizeof(*syms), glue(symcmp, SZ));
for (i = 0; i < nsyms - 1; i++) {
if (syms[i].st_size == 0) {
syms[i].st_size = syms[i + 1].st_value - syms[i].st_value;
}
} else {
g_free(syms);
syms = NULL;
}
/* String table */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment