From bdd4a67d7cd0588dd27de2a526f4f9abd47b6abc Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 15 Mar 2011 14:04:50 +0000 Subject: [PATCH] From Sukender, "Fixed a case where getUniqueName() does not work properly" --- src/osgPlugins/3ds/WriterNodeVisitor.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/osgPlugins/3ds/WriterNodeVisitor.cpp b/src/osgPlugins/3ds/WriterNodeVisitor.cpp index 3752be8df..6d699bdb5 100644 --- a/src/osgPlugins/3ds/WriterNodeVisitor.cpp +++ b/src/osgPlugins/3ds/WriterNodeVisitor.cpp @@ -623,7 +623,9 @@ std::string WriterNodeVisitor::getUniqueName(const std::string& _defaultValue, b // Nodes names: keep last directories (used only for the root name, generally named after the full file path) // Images names: keep first directories (for images) if (isNodeName) std::reverse(parentPath.begin(), parentPath.end()); - parentPath = truncateFilenameBytes(parentPath, MAX_PREFIX_LENGTH - (filename.length() + ext.length() + 1)); // +1 for the path separator + unsigned lenToDelete(filename.length() + ext.length() + 1); + lenToDelete = osg::clampBelow(lenToDelete, MAX_PREFIX_LENGTH); + parentPath = truncateFilenameBytes(parentPath, MAX_PREFIX_LENGTH - lenToDelete); // +1 for the path separator std::string::size_type separator = parentPath.find_last_of("/\\"); if (separator != std::string::npos) parentPath = parentPath.substr(0, separator); if (isNodeName) std::reverse(parentPath.begin(), parentPath.end());