From 38d91ca3feccbbd09b5936169370eb96c801a145 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 10 Jun 2016 14:36:50 +0100 Subject: [PATCH] Introduced use of local std::string to work around issue of the read header.text not being null terminated and causing a problem with the strstr call. --- src/osgPlugins/stl/ReaderWriterSTL.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/osgPlugins/stl/ReaderWriterSTL.cpp b/src/osgPlugins/stl/ReaderWriterSTL.cpp index d17d5a323..96a6f5723 100644 --- a/src/osgPlugins/stl/ReaderWriterSTL.cpp +++ b/src/osgPlugins/stl/ReaderWriterSTL.cpp @@ -475,11 +475,13 @@ osgDB::ReaderWriter::ReadResult ReaderWriterSTL::readNode(const std::string& fil return ReadResult::ERROR_IN_READING_FILE; } + std::string header_text(header.text, sizeof(header.text)); + if (stb.st_size == expectLen) { isBinary = true; } - else if (strstr(header.text, "solid") != 0) + else if (header_text.find("solid") != std::string::npos) { isBinary = false; }