From 070c664ff2a9d3a7c65a48709ee63e62d0db1391 Mon Sep 17 00:00:00 2001 From: LaShonda Hopper Date: Mon, 11 Sep 2017 13:27:59 -0400 Subject: [PATCH] [WL21389] Add out of bounds safeguard to computeShapeInfo helper (details below). * Switched direct map indexing to helper function which has out of bounds safeguard. * Also updated GeometryCache::getShapeForEntityShape default fallback return from GeometryCache::NUM_SHAPES to GeometryCache::Sphere inline with general preference to act as if a shape is a sphere in the event of an error. Changes Committed: modified: libraries/render-utils/src/GeometryCache.cpp --- libraries/render-utils/src/GeometryCache.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libraries/render-utils/src/GeometryCache.cpp b/libraries/render-utils/src/GeometryCache.cpp index 38994cfa02..492a492bf9 100644 --- a/libraries/render-utils/src/GeometryCache.cpp +++ b/libraries/render-utils/src/GeometryCache.cpp @@ -96,7 +96,8 @@ void GeometryCache::computeSimpleHullPointListForShape(const ShapeEntityItem * c } auto geometryCache = DependencyManager::get(); - const GeometryCache::ShapeData * shapeData = geometryCache->getShapeData(MAPPING[shapePtr->getShape()]); + const GeometryCache::Shape entityGeometryShape = GeometryCache::getShapeForEntityShape(shapePtr->getShape()); + const GeometryCache::ShapeData * shapeData = geometryCache->getShapeData( entityGeometryShape ); if (!shapeData){ //--EARLY EXIT--( data isn't ready for some reason... ) return; @@ -522,7 +523,7 @@ const GeometryCache::ShapeData * GeometryCache::getShapeData(const Shape shape) GeometryCache::Shape GeometryCache::getShapeForEntityShape(int entityShape) { if ((entityShape < 0) || (entityShape >= MAPPING.size())){ - return NUM_SHAPES; + return GeometryCache::Sphere; } return MAPPING[entityShape];