outelf32/64: fix uninitialized rbtree
authorMichael Scherer <misc@n4.mandriva.com>
Wed, 18 Mar 2009 21:26:29 +0000 (22:26 +0100)
committerH. Peter Anvin <hpa@linux.intel.com>
Wed, 18 Mar 2009 21:47:33 +0000 (14:47 -0700)
Fix crash caused by uninitialised memory that lead to dangling pointer
in the rbtree. This can be seen by compiling zsnes 1.50, with a file
that define many symbols, such as fxemu2c.asm.

output/outelf32.c
output/outelf64.c

index 604c353..9edce37 100644 (file)
@@ -602,6 +602,8 @@ static void elf_deflabel(char *name, int32_t segment, int64_t offset,
 
     lastsym = sym = saa_wstruct(syms);
 
+    memset(&sym->symv, 0, sizeof(struct rbtree));
+
     sym->strpos = pos;
     sym->type = is_global ? SYM_GLOBAL : 0;
     sym->other = STV_DEFAULT;
index 24d0b81..484c4ba 100644 (file)
@@ -638,6 +638,8 @@ static void elf_deflabel(char *name, int32_t segment, int64_t offset,
 
     lastsym = sym = saa_wstruct(syms);
 
+    memset(&sym->symv, 0, sizeof(struct rbtree));
+
     sym->strpos = pos;
     sym->type = is_global ? SYM_GLOBAL : 0;
     sym->other = STV_DEFAULT;