From bf96f6cda9ce9e43871cc6d94f3fc45d5f138301 Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Thu, 21 Dec 2023 19:40:45 +0100 Subject: [PATCH] Fix: failing unit tests due to "stack-use-after-scope" The return value of `get_rotation_mode_path` was stored in a `blender::StringRef` which caused the memory of the string to be freed to early. Fix by returning a `blender::StringRef` Interestingly this seems to be only an issue on ASAN builds. Pull Request: https://projects.blender.org/blender/blender/pulls/116434 --- source/blender/animrig/ANIM_rna.hh | 3 ++- source/blender/animrig/intern/anim_rna.cc | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/source/blender/animrig/ANIM_rna.hh b/source/blender/animrig/ANIM_rna.hh index d2fcb8f24f0..a22a5e6ea14 100644 --- a/source/blender/animrig/ANIM_rna.hh +++ b/source/blender/animrig/ANIM_rna.hh @@ -8,6 +8,7 @@ * \brief Helper functions for animation to interact with the RNA system. */ +#include "BLI_string_ref.hh" #include "BLI_vector.hh" #include "DNA_action_types.h" #include "RNA_types.hh" @@ -18,6 +19,6 @@ namespace blender::animrig { Vector get_rna_values(PointerRNA *ptr, PropertyRNA *prop); /** Get the rna path for the given rotation mode. */ -std::string get_rotation_mode_path(eRotationModes rotation_mode); +StringRef get_rotation_mode_path(eRotationModes rotation_mode); } // namespace blender::animrig diff --git a/source/blender/animrig/intern/anim_rna.cc b/source/blender/animrig/intern/anim_rna.cc index 91393288928..2167b7a5e6f 100644 --- a/source/blender/animrig/intern/anim_rna.cc +++ b/source/blender/animrig/intern/anim_rna.cc @@ -70,7 +70,7 @@ Vector get_rna_values(PointerRNA *ptr, PropertyRNA *prop) return values; } -std::string get_rotation_mode_path(const eRotationModes rotation_mode) +StringRef get_rotation_mode_path(const eRotationModes rotation_mode) { switch (rotation_mode) { case ROT_MODE_QUAT: