Added an explict null termination of buffer to address Coverity Scan reported issue
This commit is contained in:
@@ -172,8 +172,6 @@ load_md2 (const char *filename, const osgDB::ReaderWriter::Options* options)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(mapbase, 0, st.st_size+1);
|
||||
|
||||
if (read(file_fd, mapbase, st.st_size) != st.st_size)
|
||||
{
|
||||
close (file_fd);
|
||||
@@ -181,6 +179,9 @@ load_md2 (const char *filename, const osgDB::ReaderWriter::Options* options)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// set the last value in the mapbase to 0 to make sure the buffer is null terminated for later string reads from it
|
||||
((char*)mapbase)[st.st_size] = 0;
|
||||
|
||||
if (g_md2NormalsArray == NULL) {
|
||||
g_md2NormalsArray = new osg::Vec3Array;
|
||||
for (int i = 0; i < NUMVERTEXNORMALS; i++)
|
||||
|
||||
Reference in New Issue
Block a user