2
0
Эх сурвалжийг харах

Fix heap buffer overflow in PLY parser (#5956)

Co-authored-by: Kim Kulling <[email protected]>
tyler92 7 сар өмнө
parent
commit
f13197921b

+ 3 - 5
include/assimp/IOStreamBuffer.h

@@ -292,15 +292,13 @@ AI_FORCE_INLINE bool IOStreamBuffer<T>::getNextLine(std::vector<T> &buffer) {
 
     if (IsLineEnd(m_cache[m_cachePos])) {
         // skip line end
-        while (m_cache[m_cachePos] != '\n') {
+        do {
             ++m_cachePos;
-        }
-        ++m_cachePos;
-        if (isEndOfCache(m_cachePos, m_cacheSize)) {
-            if (!readNextBlock()) {
+            if (isEndOfCache(m_cachePos, m_cacheSize) && !readNextBlock()) {
                 return false;
             }
         }
+        while (m_cache[m_cachePos] != '\n');
     }
 
     size_t i(0);