From 295bfffc17c8f25ab65ec8151f8c2ef8c97388b6 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 18 Jan 2021 15:38:43 +0000 Subject: [PATCH] Added 0 to end of array. --- src/osgPlugins/dae/daeReader.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/osgPlugins/dae/daeReader.cpp b/src/osgPlugins/dae/daeReader.cpp index 282389fd0..839c5fc05 100644 --- a/src/osgPlugins/dae/daeReader.cpp +++ b/src/osgPlugins/dae/daeReader.cpp @@ -294,12 +294,19 @@ bool daeReader::convert( std::istream& fin ) // get the size of the file and rewind fin.seekg(0, std::ios::end); - std::streampos length = fin.tellg(); + unsigned long length = static_cast(fin.tellg()); fin.seekg(0, std::ios::beg); // use a vector as buffer and read from stream - std::vector buffer(length); + std::vector buffer(length + 1ul); + buffer[length] = 0; + fin.read(&buffer[0], length); + if (fin.fail()) + { + OSG_WARN << "daeReader::convert: Failed to read istream" << std::endl; + return false; + } domElement* loaded_element = _dae->openFromMemory(fileURI, &buffer[0]); _document = dynamic_cast(loaded_element);