mirror of
https://github.com/ChaiScript/ChaiScript.git
synced 2026-07-31 00:37:02 +08:00
The optimized for-loop in chaiscript_optimizer.hpp stored the loop counter as a stack-local int and exposed it to ChaiScript via var(&i), creating a reference. When the := operator was used inside the loop body (e.g. ret := i), it copied the raw pointers to this stack variable into the target's Data. When the function returned via exception unwinding, the stack frame was destroyed, leaving dangling pointers in the return value. Accessing these pointers in the caller (e.g. via string interpolation) caused a segfault. The fix heap-allocates the loop counter via std::make_shared<int>, so the data survives scope exit through reference counting. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| dispatchkit | ||
| language | ||
| utility | ||
| chaiscript_basic.hpp | ||
| chaiscript_defines.hpp | ||
| chaiscript_stdlib.hpp | ||
| chaiscript_threading.hpp | ||
| chaiscript.hpp | ||