Do not dereference null attribute pointer

- avoids crash described in https://github.com/google/draco/issues/171
This commit is contained in:
Pavel P 2017-08-06 22:36:03 -07:00
parent 64c045bdae
commit 6a494a8a30
2 changed files with 2 additions and 2 deletions

View File

@ -64,7 +64,7 @@ class MeshPredictionSchemeTexCoordsPortableDecoder
} }
bool SetParentAttribute(const PointAttribute *att) override { bool SetParentAttribute(const PointAttribute *att) override {
if (att->attribute_type() != GeometryAttribute::POSITION) if (!att || att->attribute_type() != GeometryAttribute::POSITION)
return false; // Invalid attribute type. return false; // Invalid attribute type.
if (att->num_components() != 3) if (att->num_components() != 3)
return false; // Currently works only for 3 component positions. return false; // Currently works only for 3 component positions.

View File

@ -59,7 +59,7 @@ const PointAttribute *SequentialAttributeDecoder::GetPortableAttribute() {
// If needed, copy point to attribute value index mapping from the final // If needed, copy point to attribute value index mapping from the final
// attribute to the portable attribute. // attribute to the portable attribute.
if (!attribute_->is_mapping_identity() && if (!attribute_->is_mapping_identity() &&
portable_attribute_->is_mapping_identity()) { portable_attribute_ && portable_attribute_->is_mapping_identity()) {
portable_attribute_->SetExplicitMapping(attribute_->indices_map_size()); portable_attribute_->SetExplicitMapping(attribute_->indices_map_size());
for (PointIndex i(0); i < attribute_->indices_map_size(); ++i) { for (PointIndex i(0); i < attribute_->indices_map_size(); ++i) {
portable_attribute_->SetPointMapEntry(i, attribute_->mapped_index(i)); portable_attribute_->SetPointMapEntry(i, attribute_->mapped_index(i));