diff options
author | Lukas Stockner <lukas.stockner@freenet.de> | 2020-02-06 05:02:29 +0300 |
---|---|---|
committer | Lukas Stockner <lukas.stockner@freenet.de> | 2020-02-06 05:29:44 +0300 |
commit | 462d566485d91afa1537ba4770829e0e43bc759b (patch) | |
tree | 91dc4ab1946b7dc7947ce5c3e9c486c71043f863 /source/blender/editors | |
parent | b4f8e3f01bc91c98cc8b37f9a6f4ab8378e807eb (diff) |
Fix unreported: Trying to create invalid UDIM tiles failed without error
Thanks to @dfelinto for spotting this!
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/space_image/image_ops.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 17c6f76a1d9..a2977b6ab90 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -4346,7 +4346,13 @@ static int tile_add_exec(bContext *C, wmOperator *op) Image *ima = CTX_data_edit_image(C); int start_tile = RNA_int_get(op->ptr, "number"); - int end_tile = min_ii(start_tile + RNA_int_get(op->ptr, "count"), IMA_UDIM_MAX); + int end_tile = start_tile + RNA_int_get(op->ptr, "count"); + + if (start_tile < 1001 || end_tile > IMA_UDIM_MAX) { + BKE_report(op->reports, RPT_ERROR, "Invalid UDIM index range was specified"); + return OPERATOR_CANCELLED; + } + bool fill_tile = RNA_boolean_get(op->ptr, "fill"); char *label = RNA_string_get_alloc(op->ptr, "label", NULL, 0); @@ -4442,8 +4448,15 @@ void IMAGE_OT_tile_add(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - RNA_def_int( - ot->srna, "number", 1002, 1001, INT_MAX, "Number", "UDIM number of the tile", 1001, 1099); + RNA_def_int(ot->srna, + "number", + 1002, + 1001, + IMA_UDIM_MAX, + "Number", + "UDIM number of the tile", + 1001, + 1099); RNA_def_int(ot->srna, "count", 1, 1, INT_MAX, "Count", "How many tiles to add", 1, 1000); RNA_def_string(ot->srna, "label", NULL, 0, "Label", "Optional tile label"); RNA_def_boolean(ot->srna, "fill", true, "Fill", "Fill new tile with a generated image"); |