mirror of
https://github.com/ChaiScript/ChaiScript.git
synced 2026-04-30 19:09:26 +08:00
The Handle_Return_Ref specialization for const references was wrapping return values in std::cref() while marking them as return values (is_return_value=true). This caused Vector.push_back() to store the reference directly without cloning, since it assumes return values are freshly created temporaries. When the source object (e.g., a map) went out of scope, the vector contained dangling references to freed memory. The fix sets is_return_value=false for const reference returns, which correctly triggers push_back to clone the value instead of storing a bare reference. This is consistent with the non-const reference handler (Handle_Return<Ret &>) which also does not set the return value flag. Co-authored-by: leftibot <leftibot@users.noreply.github.com> 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 | ||