changeset 41:7eafdb3a8074

Fixed symbol parsing to prevent string overflow
author lost
date Sat, 03 Jan 2009 19:50:30 +0000
parents d2cee0c335e7
children 4bb7b723e5b7
files src/expr.c
diffstat 1 files changed, 4 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/expr.c	Sat Jan 03 19:41:39 2009 +0000
+++ b/src/expr.c	Sat Jan 03 19:50:30 2009 +0000
@@ -390,8 +390,8 @@
 		char *sb;
 		
 		// evaluate a symbol here
-		static const char *symchars = "_.$@\\abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
-		while (strchr(symchars, (*p)[l]))
+		static const char *symchars = "_.$@?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
+		while ((*p)[l] && strchr(symchars, (*p)[l]))
 			l++;
 
 		if (l == 0)
@@ -403,8 +403,9 @@
 		t = lwasm_expr_term_create_sym(sb);
 		lwasm_expr_stack_push(s, t);
 		lwasm_expr_term_free(t);
+		(*p) += l;
+		debug_message(3, "Symbol: '%s'; (%s)", sb, *p);
 		lwasm_free(sb);
-		(*p) += l;
 		return 0;
 	}