diff --git a/src/osgPlugins/stl/ReaderWriterSTL.cpp b/src/osgPlugins/stl/ReaderWriterSTL.cpp index b9697f1de..9e23d1b00 100644 --- a/src/osgPlugins/stl/ReaderWriterSTL.cpp +++ b/src/osgPlugins/stl/ReaderWriterSTL.cpp @@ -400,12 +400,12 @@ const float StlColorDepth = float(StlColorSize); // 2^5 - 1 // Magics files have a header with a "COLOR=" field giving the color of the whole model bool fileComesFromMagics(FILE *fp, osg::Vec4& magicsColor) { - char header[80]; + std::string header(80, 0); const float magicsColorDepth = 255.f; ::rewind(fp); - if (fread((void*) &header, sizeof(header), 1, fp) != 1) + if (fread((void*) &(*header.begin()), header.size(), 1, fp) != 1) return false; if (::fseek(fp, sizeof_StlHeader, SEEK_SET)!=0) @@ -414,8 +414,7 @@ bool fileComesFromMagics(FILE *fp, osg::Vec4& magicsColor) } std::string magicsColorPattern ("COLOR="); - std::string headerStr = std::string(header); - if(size_t colorFieldPos = headerStr.find(magicsColorPattern) != std::string::npos) + if(size_t colorFieldPos = header.find(magicsColorPattern) != std::string::npos) { int colorIndex = colorFieldPos + magicsColorPattern.size() - 1; float r = (uint8_t)header[colorIndex] / magicsColorDepth;