]> git.proxmox.com Git - qemu.git/commitdiff
linux-user: Protect against allocation failure in load_symbols.
authorRichard Henderson <rth@twiddle.net>
Thu, 29 Jul 2010 16:37:01 +0000 (09:37 -0700)
committermalc <av1474@comtv.ru>
Thu, 29 Jul 2010 16:54:35 +0000 (20:54 +0400)
Cc: malc <av1474@comtv.ru>
Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: malc <av1474@comtv.ru>
linux-user/elfload.c

index a53285ae39048c7bc348535ddd382b2e84c8e9df..33d776de41a69368854d85c17e4e6b181168faa0 100644 (file)
@@ -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;