summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/eval.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/eval.c b/src/eval.c
index 081f098..a99ad4d 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -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);