Fix #132568: Grease Pencil: runtime error: null pointer as argument
The passed `StringRef` can be empty, so we shouldn't pass it to `BLI_strdupn` in this case. If an empty string is passed to either `set` function makes sure the previous `char *` is freed and set to `nullptr`. Pull Request: https://projects.blender.org/blender/blender/pulls/133042
This commit is contained in:
@@ -1460,8 +1460,11 @@ void Layer::set_parent_bone_name(const StringRef new_name)
|
||||
{
|
||||
if (this->parsubstr != nullptr) {
|
||||
MEM_freeN(this->parsubstr);
|
||||
this->parsubstr = nullptr;
|
||||
}
|
||||
if (!new_name.is_empty()) {
|
||||
this->parsubstr = BLI_strdupn(new_name.data(), new_name.size());
|
||||
}
|
||||
this->parsubstr = BLI_strdupn(new_name.data(), new_name.size());
|
||||
}
|
||||
|
||||
float4x4 Layer::parent_to_world(const Object &parent) const
|
||||
@@ -1505,8 +1508,11 @@ void Layer::set_view_layer_name(const StringRef new_name)
|
||||
{
|
||||
if (this->viewlayername != nullptr) {
|
||||
MEM_freeN(this->viewlayername);
|
||||
this->viewlayername = nullptr;
|
||||
}
|
||||
if (!new_name.is_empty()) {
|
||||
this->viewlayername = BLI_strdupn(new_name.data(), new_name.size());
|
||||
}
|
||||
this->viewlayername = BLI_strdupn(new_name.data(), new_name.size());
|
||||
}
|
||||
|
||||
LayerGroup::LayerGroup()
|
||||
|
||||
Reference in New Issue
Block a user