From 436f1a2afad33e74adb58f9db681dbc6e76fb591 Mon Sep 17 00:00:00 2001 From: Philipp Oeser Date: Fri, 28 Dec 2018 16:14:39 +0100 Subject: Alembic import: Fix crash with mcol indices out of bounds Part of T57377 Reviewers: sybren Maniphest Tasks: T57377 Differential Revision: https://developer.blender.org/D3847 --- source/blender/alembic/intern/abc_customdata.cc | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'source/blender/alembic') diff --git a/source/blender/alembic/intern/abc_customdata.cc b/source/blender/alembic/intern/abc_customdata.cc index da69938f34f..89ee753c618 100644 --- a/source/blender/alembic/intern/abc_customdata.cc +++ b/source/blender/alembic/intern/abc_customdata.cc @@ -284,6 +284,7 @@ static size_t mcols_out_of_bounds_check( const size_t array_size, const std::string & iobject_full_name, const PropertyHeader &prop_header, + bool &r_is_out_of_bounds, bool &r_bounds_warning_given) { if (color_index < array_size) { @@ -298,7 +299,7 @@ static size_t mcols_out_of_bounds_check( << prop_header.getName() << std::endl; r_bounds_warning_given = true; } - + r_is_out_of_bounds = true; return 0; } @@ -379,12 +380,15 @@ static void read_custom_data_mcols(const std::string & iobject_full_name, color_index = (*indices)[color_index]; } if (use_c3f_ptr) { + bool is_mcols_out_of_bounds = false; color_index = mcols_out_of_bounds_check( color_index, c3f_ptr->size(), iobject_full_name, prop_header, - bounds_warning_given); - + is_mcols_out_of_bounds, bounds_warning_given); + if (is_mcols_out_of_bounds) { + continue; + } const Imath::C3f &color = (*c3f_ptr)[color_index]; cface->a = unit_float_to_uchar_clamp(color[0]); cface->r = unit_float_to_uchar_clamp(color[1]); @@ -392,12 +396,15 @@ static void read_custom_data_mcols(const std::string & iobject_full_name, cface->b = 255; } else { + bool is_mcols_out_of_bounds = false; color_index = mcols_out_of_bounds_check( color_index, c4f_ptr->size(), iobject_full_name, prop_header, - bounds_warning_given); - + is_mcols_out_of_bounds, bounds_warning_given); + if (is_mcols_out_of_bounds) { + continue; + } const Imath::C4f &color = (*c4f_ptr)[color_index]; cface->a = unit_float_to_uchar_clamp(color[0]); cface->r = unit_float_to_uchar_clamp(color[1]); -- cgit v1.2.3