mirror of
https://github.com/RTimothyEdwards/magic.git
synced 2026-08-29 09:30:46 +02:00
API docs indicate the original usage seems ok. Calling Tcl_GetIndexFromObj() is allowed with a refcount == 0. But in actual usage it leaks the Tcl_NewStringObj() memory across the Tcl_EvalObjv() call like the object accounting system doesn't work on that anymore (because the use of Tcl_EvalObjv() disrupted things). Looking at the code nearby it increments refs (for all recently created objs) and decrements around Tcl_EvalEx() for the actual data the 'eval' needs pinned and is working on. If we just repeat this same pattern but with 'objv0' the memory leak is gone. The decrement must wake it up / make it remember what to do. So this required covering all the exit paths to decrement as well.