Skip to content

Commit e8a9064

Browse files
committed
Added 0 to end of array.
1 parent a7360d6 commit e8a9064

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

src/osgPlugins/dae/daeReader.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,12 +294,19 @@ bool daeReader::convert( std::istream& fin )
294294

295295
// get the size of the file and rewind
296296
fin.seekg(0, std::ios::end);
297-
std::streampos length = fin.tellg();
297+
unsigned long length = static_cast<unsigned long>(fin.tellg());
298298
fin.seekg(0, std::ios::beg);
299299

300300
// use a vector as buffer and read from stream
301-
std::vector<char> buffer(length);
301+
std::vector<char> buffer(length + 1ul);
302+
buffer[length] = 0;
303+
302304
fin.read(&buffer[0], length);
305+
if (fin.fail())
306+
{
307+
OSG_WARN << "daeReader::convert: Failed to read istream" << std::endl;
308+
return false;
309+
}
303310

304311
domElement* loaded_element = _dae->openFromMemory(fileURI, &buffer[0]);
305312
_document = dynamic_cast<domCOLLADA*>(loaded_element);

0 commit comments

Comments
 (0)