diff options
author | Philipp Oeser <info@graphics-engineer.com> | 2018-12-28 18:14:39 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@stuvel.eu> | 2018-12-28 18:47:58 +0300 |
commit | 436f1a2afad33e74adb58f9db681dbc6e76fb591 (patch) | |
tree | a3fe1f6dbfc34ce59fe4ec51814f0e9b2b81e602 /source/blender/alembic | |
parent | da7a3424786043ae799fc6915347021872f5216b (diff) |
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
Diffstat (limited to 'source/blender/alembic')
-rw-r--r-- | source/blender/alembic/intern/abc_customdata.cc | 17 |
1 files changed, 12 insertions, 5 deletions
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]); |