Replace c char array with std::string to address Coverity scan reported issue
This commit is contained in:
parent
3459e8f4fd
commit
95eb5e2ad6
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user