From 1ec80a176e581054ac2c84a23d20e47866fd368a Mon Sep 17 00:00:00 2001 From: Philipp Oeser Date: Tue, 8 Aug 2023 10:34:02 +0200 Subject: [PATCH] Fix #93103: modifier iterations can be set to a negative value Sanitize "iterations" in a couple of modifiers (namely Smooth, Corrective Smooth, Laplacian Smooth & Laplacian Deform) to always have a hard limit of 0. Putting in negative values does not make sense (and could have caused an infinite loop since the negative value is cast to unsigned internally in the case of the 'Corrective Smooth' modifier). --- source/blender/makesrna/intern/rna_modifier.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/source/blender/makesrna/intern/rna_modifier.cc b/source/blender/makesrna/intern/rna_modifier.cc index 6fc037151a5..6e9ab9df582 100644 --- a/source/blender/makesrna/intern/rna_modifier.cc +++ b/source/blender/makesrna/intern/rna_modifier.cc @@ -3281,8 +3281,9 @@ static void rna_def_modifier_smooth(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Factor", "Strength of modifier effect"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); - prop = RNA_def_property(srna, "iterations", PROP_INT, PROP_NONE); + prop = RNA_def_property(srna, "iterations", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, nullptr, "repeat"); + RNA_def_property_range(prop, 0, SHRT_MAX); RNA_def_property_ui_range(prop, 0, 30, 1, -1); RNA_def_property_ui_text(prop, "Repeat", ""); RNA_def_property_update(prop, 0, "rna_Modifier_update"); @@ -3352,8 +3353,9 @@ static void rna_def_modifier_correctivesmooth(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Lambda Factor", "Smooth effect factor"); RNA_def_property_update(prop, 0, "rna_CorrectiveSmoothModifier_update"); - prop = RNA_def_property(srna, "iterations", PROP_INT, PROP_NONE); + prop = RNA_def_property(srna, "iterations", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, nullptr, "repeat"); + RNA_def_property_range(prop, 0, SHRT_MAX); RNA_def_property_ui_range(prop, 0, 200, 1, -1); RNA_def_property_ui_text(prop, "Repeat", ""); RNA_def_property_update(prop, 0, "rna_CorrectiveSmoothModifier_update"); @@ -3464,8 +3466,9 @@ static void rna_def_modifier_laplaciansmooth(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Lambda Border", "Lambda factor in border"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); - prop = RNA_def_property(srna, "iterations", PROP_INT, PROP_NONE); + prop = RNA_def_property(srna, "iterations", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, nullptr, "repeat"); + RNA_def_property_range(prop, 0, SHRT_MAX); RNA_def_property_ui_range(prop, 0, 200, 1, -1); RNA_def_property_ui_text(prop, "Repeat", ""); RNA_def_property_update(prop, 0, "rna_Modifier_update"); @@ -6240,8 +6243,9 @@ static void rna_def_modifier_laplaciandeform(BlenderRNA *brna) RNA_def_property_string_funcs( prop, nullptr, nullptr, "rna_LaplacianDeformModifier_anchor_grp_name_set"); - prop = RNA_def_property(srna, "iterations", PROP_INT, PROP_NONE); + prop = RNA_def_property(srna, "iterations", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, nullptr, "repeat"); + RNA_def_property_range(prop, 0, SHRT_MAX); RNA_def_property_ui_range(prop, 1, 50, 1, -1); RNA_def_property_ui_text(prop, "Repeat", ""); RNA_def_property_update(prop, 0, "rna_Modifier_update"); -- 2.30.2