aboutsummaryrefslogtreecommitdiff
path: root/linux-user
diff options
context:
space:
mode:
authorRichard Henderson <rth@twiddle.net>2010-07-29 09:37:01 -0700
committermalc <av1474@comtv.ru>2010-07-29 20:54:35 +0400
commit5d5c99300d91d67c3f70058d2431a633028e3a9e (patch)
treea6aa3414233adb4aeb09fa2db419558262e34d4f /linux-user
parent58f5c1eb8984897170e98efb9b194f07cc06cc39 (diff)
downloadqemu-5d5c99300d91d67c3f70058d2431a633028e3a9e.zip
qemu-5d5c99300d91d67c3f70058d2431a633028e3a9e.tar.gz
qemu-5d5c99300d91d67c3f70058d2431a633028e3a9e.tar.bz2
linux-user: Protect against allocation failure in load_symbols.
Cc: malc <av1474@comtv.ru> Signed-off-by: Richard Henderson <rth@twiddle.net> Signed-off-by: malc <av1474@comtv.ru>
Diffstat (limited to 'linux-user')
-rw-r--r--linux-user/elfload.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index a53285a..33d776d 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -1546,7 +1546,17 @@ static void load_symbols(struct elfhdr *hdr, int fd, abi_ulong load_bias)
}
}
+ /* Attempt to free the storage associated with the local symbols
+ that we threw away. Whether or not this has any effect on the
+ memory allocation depends on the malloc implementation and how
+ many symbols we managed to discard. */
syms = realloc(syms, nsyms * sizeof(*syms));
+ if (syms == NULL) {
+ free(s);
+ free(strings);
+ return;
+ }
+
qsort(syms, nsyms, sizeof(*syms), symcmp);
s->disas_num_syms = nsyms;