Godot Engine – Multi-platform 2D and 3D game engine
Fix use-after-free by reordering members
cpl-s-matsuyama83ae7c94eff1
diff --git a/modules/gdscript/gdscript_lambda_callable.h b/modules/gdscript/gdscript_lambda_callable.hindex a4e0c956a00..f2e283fd973 100644--- a/modules/gdscript/gdscript_lambda_callable.h+++ b/modules/gdscript/gdscript_lambda_callable.h@@ -41,8 +41,11 @@ class GDScriptFunction;class GDScriptInstance;class GDScriptLambdaCallable : public CallableCustom {- GDScript::UpdatableFuncPtr function;+ // `script` must have a longer lifetime than `function`.+ // `~UpdatableFuncPtr()` locks the GDScript mutex it points to via a raw pointer.+ // As members are destroyed in reverse order of declaration, the reference must be declared first.Ref<GDScript> script;+ GDScript::UpdatableFuncPtr function;uint32_t h;Vector<Variant> captures;