Fix T94085: Crash with empty stroke list

This commit is contained in:
Campbell Barton 2022-02-15 19:48:14 +11:00
parent d1c7a252eb
commit 7083ea36e2
Notes: blender-bot 2023-02-14 08:45:12 +01:00
Referenced by issue #94085, Calling bpy.ops.curve.draw with an empty stroke list causes a segfault
1 changed files with 8 additions and 0 deletions

View File

@ -588,6 +588,14 @@ static bool curve_draw_init(bContext *C, wmOperator *op, bool is_invoke)
cdd->vc.scene = CTX_data_scene(C);
cdd->vc.view_layer = CTX_data_view_layer(C);
cdd->vc.obedit = CTX_data_edit_object(C);
/* Using an empty stroke complicates logic later,
* it's simplest to disallow early on (see: T94085). */
if (RNA_collection_length(op->ptr, "stroke") == 0) {
MEM_freeN(cdd);
BKE_report(op->reports, RPT_ERROR, "The \"stroke\" cannot be empty");
return false;
}
}
op->customdata = cdd;