From 2e111130724d08623c6a6b0f3970a414417df64e Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 21 May 2015 14:11:32 +0000 Subject: [PATCH] Fixed memory error associated with reading over the end of container due to an unbounded while loop. git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14866 16af8721-9629-0410-8352-f15c8da7e697 --- src/osgText/Text3D.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/osgText/Text3D.cpp b/src/osgText/Text3D.cpp index c20596ee8..71f8f13c4 100644 --- a/src/osgText/Text3D.cpp +++ b/src/osgText/Text3D.cpp @@ -369,12 +369,11 @@ void Text3D::computeGlyphRepresentation() ++itr; } - if (itr!=_text.end()) - { - // skip over spaces and return. - while (*itr==' ') ++itr; - if (*itr=='\n') ++itr; - } + // skip over spaces + while ((itr!=_text.end()) && (*itr==' ')) ++itr; + + // skip over return + if ((itr!=_text.end()) && (*itr=='\n')) ++itr; // move to new line. switch(_layout)