Fix potential null pointer de-reference
Refactoring &
This commit is contained in:
@@ -1359,8 +1359,6 @@ bool BKE_collection_object_add_notest(Main *bmain, Collection *collection, Objec
|
||||
return false;
|
||||
}
|
||||
|
||||
const int id_create_flag = (collection->id.tag & LIB_TAG_NO_MAIN) ? LIB_ID_CREATE_NO_MAIN : 0;
|
||||
|
||||
/* Only case where this pointer can be nullptr is when scene itself is linked, this case should
|
||||
* never be reached. */
|
||||
BLI_assert(collection != nullptr);
|
||||
@@ -1368,6 +1366,7 @@ bool BKE_collection_object_add_notest(Main *bmain, Collection *collection, Objec
|
||||
return false;
|
||||
}
|
||||
|
||||
const int id_create_flag = (collection->id.tag & LIB_TAG_NO_MAIN) ? LIB_ID_CREATE_NO_MAIN : 0;
|
||||
if (!collection_object_add(bmain, collection, ob, nullptr, id_create_flag, true)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -700,9 +700,9 @@ bool get_effector_data(EffectorCache *eff,
|
||||
else if (eff->pd && eff->pd->shape == PFIELD_SHAPE_POINTS) {
|
||||
/* TODO: hair and points object support */
|
||||
const Mesh *mesh_eval = BKE_object_get_evaluated_mesh(eff->ob);
|
||||
const blender::Span<blender::float3> positions = mesh_eval->vert_positions();
|
||||
const blender::Span<blender::float3> vert_normals = mesh_eval->vert_normals();
|
||||
if (mesh_eval != nullptr) {
|
||||
const blender::Span<blender::float3> positions = mesh_eval->vert_positions();
|
||||
const blender::Span<blender::float3> vert_normals = mesh_eval->vert_normals();
|
||||
copy_v3_v3(efd->loc, positions[*efd->index]);
|
||||
copy_v3_v3(efd->nor, vert_normals[*efd->index]);
|
||||
|
||||
|
||||
@@ -3110,7 +3110,7 @@ bool ui_but_string_set(bContext *C, uiBut *but, const char *str)
|
||||
{
|
||||
RNA_property_pointer_set(&but->rnapoin, but->rnaprop, rptr, nullptr);
|
||||
}
|
||||
else if (search_but->item_active != nullptr) {
|
||||
else if (search_but && search_but->item_active != nullptr) {
|
||||
rptr = RNA_pointer_create(nullptr,
|
||||
RNA_property_pointer_type(&but->rnapoin, but->rnaprop),
|
||||
search_but->item_active);
|
||||
|
||||
Reference in New Issue
Block a user