Fix more crashes attempting to run operators in unexpected contexts

Add missing NULL checks for:

- OBJECT_OT_transform_to_mouse
- GPENCIL_OT_time_segment_remove
This commit is contained in:
Campbell Barton
2023-04-30 15:21:10 +10:00
parent 5d59f4ad7b
commit 358ce4f52b
2 changed files with 4 additions and 1 deletions

View File

@@ -4031,7 +4031,7 @@ static int object_transform_to_mouse_exec(bContext *C, wmOperator *op)
MEM_freeN(objects);
}
else {
else if (CTX_wm_region_view3d(C)) {
int mval[2];
if (object_add_drop_xy_get(C, op, &mval)) {
float cursor[3];

View File

@@ -1024,6 +1024,9 @@ static int time_segment_remove_exec(bContext *C, wmOperator *op)
TimeGpencilModifierData *gpmd = (TimeGpencilModifierData *)gpencil_edit_modifier_property_get(
op, ob, eGpencilModifierType_Time);
if (gpmd == NULL) {
return OPERATOR_CANCELLED;
}
if (gpmd->segment_active_index < 0 || gpmd->segment_active_index >= gpmd->segments_len) {
return OPERATOR_CANCELLED;
}