Fix: Incorrect use of StringRef::data()

The returned pointer shouldn't be passed to a function expecting
a null terminated C string. Use the StringRef::copy function instead
which is more efficient anyway since it doesn't have to measure the
size of the string again.
This commit is contained in:
Hans Goudey
2024-12-18 18:50:11 -05:00
parent a9f127975f
commit ca6538b596
2 changed files with 4 additions and 5 deletions

View File

@@ -1593,7 +1593,7 @@ static void legacy_object_modifier_influence(GreasePencilModifierInfluenceData &
{
influence.flag = 0;
STRNCPY(influence.layer_name, layername.data());
layername.copy(influence.layer_name);
if (invert_layer) {
influence.flag |= GREASE_PENCIL_INFLUENCE_INVERT_LAYER_FILTER;
}
@@ -1620,7 +1620,7 @@ static void legacy_object_modifier_influence(GreasePencilModifierInfluenceData &
influence.flag |= GREASE_PENCIL_INFLUENCE_INVERT_MATERIAL_PASS_FILTER;
}
STRNCPY(influence.vertex_group_name, vertex_group_name.data());
vertex_group_name.copy(influence.vertex_group_name);
if (invert_vertex_group) {
influence.flag |= GREASE_PENCIL_INFLUENCE_INVERT_VERTEX_GROUP;
}

View File

@@ -483,7 +483,6 @@ static void write_node_socket_interface(BlendWriter *writer, const bNodeSocket *
static bNodeSocket *make_socket(bNodeTree *ntree,
const eNodeSocketInOut in_out,
const StringRef idname,
const StringRef name,
const StringRef identifier)
{
@@ -501,8 +500,8 @@ static bNodeSocket *make_socket(bNodeTree *ntree,
sock->limit = (in_out == SOCK_IN ? 1 : 0xFFF);
STRNCPY(sock->identifier, identifier.data());
STRNCPY(sock->name, name.data());
identifier.copy(sock->identifier);
name.copy(sock->name);
sock->storage = nullptr;
sock->flag |= SOCK_COLLAPSED;