Mercurial > hg-old > index.cgi
comparison lwasm/pseudo.c @ 221:271c0ef9ea60
Fixed segfault in import/extern pseudo op
author | lost |
---|---|
date | Sat, 09 May 2009 16:32:47 +0000 |
parents | bae1e3ecdce1 |
children | 058f18119025 |
comparison
equal
deleted
inserted
replaced
220:2b254f02b252 | 221:271c0ef9ea60 |
---|---|
1029 { | 1029 { |
1030 register_error(as, l, 1, "Cannot declare external symbols within a section"); | 1030 register_error(as, l, 1, "Cannot declare external symbols within a section"); |
1031 return; | 1031 return; |
1032 } | 1032 } |
1033 | 1033 |
1034 lwasm_register_symbol(as, l, l -> sym, 0, SYMBOL_EXTERN); | 1034 if (l -> sym) |
1035 { | |
1036 lwasm_register_symbol(as, l, l -> sym, 0, SYMBOL_EXTERN); | |
1037 return; | |
1038 } | |
1039 | |
1040 while (**p) | |
1041 { | |
1042 char *sym2, *sym3; | |
1043 for (sym2 = *p; **p && !isspace(**p) && **p != ','; (*p)++) | |
1044 /* do nothing */ ; | |
1045 | |
1046 if (l -> sym) | |
1047 lwasm_free(l -> sym); | |
1048 | |
1049 sym3 = lwasm_alloc(*p - sym2 + 1); | |
1050 memcpy(sym3, sym2, *p - sym2); | |
1051 sym3[*p - sym2] = '\0'; | |
1052 | |
1053 l -> sym = sym3; | |
1054 debug_message(2, "import symbol: '%s'", sym3); | |
1055 lwasm_register_symbol(as, l, l -> sym, 0, SYMBOL_EXTERN); | |
1056 if (**p && (**p != ',')) | |
1057 { | |
1058 register_error(as, l, 1, "Bad import list"); | |
1059 return; | |
1060 } | |
1061 if (**p == ',') | |
1062 (*p)++; | |
1063 } | |
1064 if (!(l -> sym)) | |
1065 register_error(as, l, 1, "Bad import list"); | |
1035 } | 1066 } |
1036 | 1067 |
1037 OPFUNC(pseudo_export) | 1068 OPFUNC(pseudo_export) |
1038 { | 1069 { |
1039 lwasm_symbol_ent_t *se; | 1070 lwasm_symbol_ent_t *se; |