diff --git a/source/blender/modifiers/intern/MOD_grease_pencil_util.cc b/source/blender/modifiers/intern/MOD_grease_pencil_util.cc index 651f0c399ad..c18eb6cfc25 100644 --- a/source/blender/modifiers/intern/MOD_grease_pencil_util.cc +++ b/source/blender/modifiers/intern/MOD_grease_pencil_util.cc @@ -190,12 +190,13 @@ void draw_custom_curve_settings(const bContext * /*C*/, uiLayout *layout, Pointe static Vector get_grease_pencil_material_passes(const Object *ob) { short *totcol = BKE_object_material_len_p(const_cast(ob)); - Vector result(*totcol); + Vector result(*totcol, 0); Material *ma = nullptr; for (short i = 0; i < *totcol; i++) { - ma = BKE_object_material_get(const_cast(ob), i + 1); - /* Pass index of the grease pencil material. */ - result[i] = ma->gp_style->index; + if (ma = BKE_object_material_get(const_cast(ob), i + 1)) { + /* Pass index of the grease pencil material. */ + result[i] = ma->gp_style->index; + } } return result; }