Possible memory leaks
vysocan opened this issue · comments
Hello,
first thanks for this library. I plan to use it as scripting language inside my STM32 project.
As MCUs are short on memory and generally have problems with alloc/free I'm using memory manager inside statically allocated array. This allows me to see how the memory is used or freed after tcl_eval() and tcl_destroy(). I found one problem which I yet do not understand. When I try to run this tcl:
= y";
I receive lexer error of course, but I see 2 not freed fragment inside memory:
=
y
I tried to add debug messages to all function that use tcl_malloc() or tcl_realloc, but I did not find any match to pointer address.
I quess there can be some addition to tcl_next(), somewhere after :
} else if (*s == '"') {
*q = !*q;
*from = *to = s + 1;
if (*q) {
to check for quote being closed. But it would be just to indicate to user what is the problem.
Not I'm not sure where it gets allocated, I have no idea how to free it.
Thanks for any advice.
OK simple enough solution to my problem:
tcl_list_free(list); tcl_free(cur);
Needs to be added in case of TERROR before exit of tcl_eval().