jsonnet icon indicating copy to clipboard operation
jsonnet copied to clipboard

Memory leaks in //cpp/libjsonnet++.cc

Open fuwang-pony opened this issue 4 years ago • 1 comments

I find a bug that causes memory leaking in //cpp/libjsonnet++.cc.

In Line 97, the output char array jsonnet_output has not been freed. To my understanding, we need a ::jsonnet_realloc(vm_, jsonnet_output, 0); to free the memory before function returns.

The same problem in Line 113, 149, and 165.

fuwang-pony avatar Sep 23 '20 03:09 fuwang-pony

Thanks for reporting. The C++ bindings are not very heavily exercised (I think most people use C bindings even from C++). We definitely should check it out and fix it, if it's an actual leak.

Also we might consider setting up some tests with valgrind.

sbarzowski avatar Sep 23 '20 08:09 sbarzowski

I think this was fixed by #1013 (valgrind still reports no leaks when running libjsonnet++_test on master now). Closing as complete.

johnbartholomew avatar Mar 10 '24 11:03 johnbartholomew