Fix memory leak in for-counter.

Switch from strdup() to vm_strdup(), and make sure the allocated strings get freed after usage.
This commit is contained in:
MageKing17 committed 2015-04-27 03:06:28 -07:00
1 parent 83b59fb76c
commit 9ec10dd3e6
1 file changed
+6 -1
+6 -1
View File
@@ -8969,12 +8969,17 @@ int eval_for_counter(int arg_handler_node, int condition_node)
for (i = counter_start; ((counter_step > 0) ? i <= counter_stop : i >= counter_stop); i += counter_step)
{
sprintf(buf, "%d", i);
argument_vector.push_back(strdup(buf));
argument_vector.push_back(vm_strdup(buf));
}
// test the whole argument vector
num_valid_arguments = test_argument_vector_for_condition(argument_vector, true, condition_node, &num_true, &num_false, &num_known_true, &num_known_false);
while (!argument_vector.empty()) {
vm_free(argument_vector.back());
argument_vector.pop_back();
}
// use the sexp_or algorithm
if (num_known_true || num_true)
return SEXP_TRUE;