From 2f65eda7bdecf408bd562fd7d2d4d6ed22d361c0 Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Sun, 26 Feb 2017 22:35:45 -0800 Subject: [PATCH] Try to fix reading freed memory in eval.c. This occurred when the null term was reached - the token was freed, but no error was thrown (it's just the end of the string), so the program attempted to increment the index using freed token data. --- src/eval.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/eval.c b/src/eval.c index fa61eb3..9e51176 100644 --- a/src/eval.c +++ b/src/eval.c @@ -209,7 +209,7 @@ liblex_result eval_all(char* string, int index, eval_config* config, ll* matches result = ll_append(matches, new_match) == LIBDS_SUCCESS ? LIBLEX_SUCCESS : LIBLEX_MALLOC; } } - if(result == LIBLEX_SUCCESS){ + if(result == LIBLEX_SUCCESS && string[index] != '\0'){ index += new_match->to - new_match->from; } } else {