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
This commit is contained in:
Christoph Lendenfeld
2023-12-21 19:40:45 +01:00
committed by Sybren A. Stüvel
parent 9bbe81b630
commit bf96f6cda9
2 changed files with 3 additions and 2 deletions
+2 -1
View File
@@ -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<float> 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
+1 -1
View File
@@ -70,7 +70,7 @@ Vector<float> 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: