From 32e8f6adc386248c346be5a27bb1ddf332bf71af Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 1 Jun 2010 15:20:30 +0000 Subject: [PATCH] From Michael Platings, "MorphGeometry fix: this fixes a crash found by Alessandro Terenzi" --- src/osgAnimation/MorphGeometry.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/osgAnimation/MorphGeometry.cpp b/src/osgAnimation/MorphGeometry.cpp index 093e099b2..8cabc9ffa 100644 --- a/src/osgAnimation/MorphGeometry.cpp +++ b/src/osgAnimation/MorphGeometry.cpp @@ -24,7 +24,7 @@ #include #include -#include +#include using namespace osgAnimation; @@ -255,9 +255,15 @@ bool UpdateMorph::link(osgAnimation::Channel* channel) { // Typically morph geometries only have the weights for morph targets animated - // Expect a weight value - // TODO Should we make this more generic to handle other things than single values? - int weightIndex = atoi(channel->getName().c_str()); + std::istringstream iss(channel->getName()); + + int weightIndex; + iss >> weightIndex; + + if (iss.fail()) + { + return false; + } if (weightIndex >= 0) {