History

[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

LaShonda Hopper committed 9 years ago

Commit 070c6641 parent d2350971 file · +3 −2Browse files

Showing the changes to libraries/render-utils/src/GeometryCache.cpp (1 of 1 file). Show all

Unified · Split

libraries/render-utils/src/GeometryCache.cpp+3−2
@@ -96,7 +96,8 @@ void GeometryCache::computeSimpleHullPointListForShape(const ShapeEntityItem * c · 95 unmodified lines
96 }96 }
97 97
98 auto geometryCache = DependencyManager::get<GeometryCache>();98 auto geometryCache = DependencyManager::get<GeometryCache>();
99 const GeometryCache::ShapeData * shapeData = geometryCache->getShapeData(MAPPING[shapePtr->getShape()]);99 const GeometryCache::Shape entityGeometryShape = GeometryCache::getShapeForEntityShape(shapePtr->getShape());
100 const GeometryCache::ShapeData * shapeData = geometryCache->getShapeData( entityGeometryShape );
100 if (!shapeData){101 if (!shapeData){
101 //--EARLY EXIT--( data isn't ready for some reason... )102 //--EARLY EXIT--( data isn't ready for some reason... )
102 return;103 return;
@@ -522,7 +523,7 @@ const GeometryCache::ShapeData * GeometryCache::getShapeData(const Shape shape) · 419 unmodified lines
522 523
523GeometryCache::Shape GeometryCache::getShapeForEntityShape(int entityShape) {524GeometryCache::Shape GeometryCache::getShapeForEntityShape(int entityShape) {
524 if ((entityShape < 0) || (entityShape >= MAPPING.size())){525 if ((entityShape < 0) || (entityShape >= MAPPING.size())){
525 return NUM_SHAPES;526 return GeometryCache::Sphere;
526 }527 }
527 528
528 return MAPPING[entityShape];529 return MAPPING[entityShape];

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t