leftibot f1a0c2ae41 Fix #635: Segfault in optimized for-loop when := copies stack-local variable
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>
2026-04-11 09:35:51 -06:00
..
chaiscript_algebraic.hpp change .clang-format and reformat code with clang-format 11 2021-05-24 10:44:15 +02:00
chaiscript_common.hpp Fix #17: Add const variables in ChaiScript (#643) 2026-04-10 22:12:13 -06:00
chaiscript_engine.hpp Fix #256: ChaiScript::get_locals() does not show functions (#640) 2026-04-11 07:57:09 -06:00
chaiscript_eval.hpp Fix #17: Add const variables in ChaiScript (#643) 2026-04-10 22:12:13 -06:00
chaiscript_optimizer.hpp Fix #635: Segfault in optimized for-loop when := copies stack-local variable 2026-04-11 09:35:51 -06:00
chaiscript_parser.hpp Fix #592: Local variable saw_eol in Class_Statements() was always true (#646) 2026-04-11 08:32:27 -06:00
chaiscript_posix.hpp change .clang-format and reformat code with clang-format 11 2021-05-24 10:44:15 +02:00
chaiscript_prelude_docs.hpp Fix #12: Document reflection and introspection capabilities 2026-04-09 21:43:56 -06:00
chaiscript_prelude.hpp change .clang-format and reformat code with clang-format 11 2021-05-24 10:44:15 +02:00
chaiscript_tracer.hpp change .clang-format and reformat code with clang-format 11 2021-05-24 10:44:15 +02:00
chaiscript_unknown.hpp change .clang-format and reformat code with clang-format 11 2021-05-24 10:44:15 +02:00
chaiscript_windows.hpp change .clang-format and reformat code with clang-format 11 2021-05-24 10:44:15 +02:00