diff options
| -rw-r--r-- | src/eval.c | 16 |
1 files changed, 11 insertions, 5 deletions
@@ -131,7 +131,7 @@ sym_t* try_eval_internal(sym_t* symbol, hashtable_t* symbolScope) { litType_t firstType = NO_TYPE; int firstInt = 0; float firstFloat = 0; - char* firstString; + char* firstString = NULL; for (int i = 0; i < symbol->argCount; i++) { sym_t* v = eval(symbol->args[i], symbolScope); /* initialize */ @@ -165,17 +165,23 @@ sym_t* try_eval_internal(sym_t* symbol, hashtable_t* symbolScope) { } } else if (v->litType == STRING) { - char* ss = symtos(v); - if (strcmp(ss, firstString) != 0) { + if (firstType == STRING) { + char* ss = symtos(v); + if (strcmp(ss, firstString) != 0) { + destroy_sym(v); + free(firstString); + return init_sym_int(0); + } + } + else { destroy_sym(v); - free(firstString); return init_sym_int(0); } destroy_sym(v); } } } - if (firstType == STRING) { + if (firstString != NULL) { free(firstString); } return init_sym_int(1); |
