Commit e04a7b16 authored by hybrid's avatar hybrid

Fix OBJ reader which could run over end-of-file or line ends due to some minor...

Fix OBJ reader which could run over end-of-file or line ends due to some minor bugs in the parser. Fix prepared by tonic

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@3604 dfc29bdd-3216-0410-991c-e03cc46cb475
parent a4dc43f5
...@@ -219,7 +219,7 @@ IAnimatedMesh* COBJMeshFileLoader::createMesh(io::IReadFile* file) ...@@ -219,7 +219,7 @@ IAnimatedMesh* COBJMeshFileLoader::createMesh(io::IReadFile* file)
Idx[1] = Idx[2] = -1; Idx[1] = Idx[2] = -1;
// read in next vertex's data // read in next vertex's data
u32 wlength = copyWord(vertexWord, linePtr, WORD_BUFFER_LENGTH, bufEnd); u32 wlength = copyWord(vertexWord, linePtr, WORD_BUFFER_LENGTH, endPtr);
// this function will also convert obj's 1-based index to c++'s 0-based index // this function will also convert obj's 1-based index to c++'s 0-based index
retrieveVertexIndices(vertexWord, Idx, vertexWord+wlength+1, vertexBuffer.size(), textureCoordBuffer.size(), normalsBuffer.size()); retrieveVertexIndices(vertexWord, Idx, vertexWord+wlength+1, vertexBuffer.size(), textureCoordBuffer.size(), normalsBuffer.size());
v.Pos = vertexBuffer[Idx[0]]; v.Pos = vertexBuffer[Idx[0]];
...@@ -830,7 +830,8 @@ core::stringc COBJMeshFileLoader::copyLine(const c8* inBuf, const c8* bufEnd) ...@@ -830,7 +830,8 @@ core::stringc COBJMeshFileLoader::copyLine(const c8* inBuf, const c8* bufEnd)
break; break;
++ptr; ++ptr;
} }
return core::stringc(inBuf, (u32)(ptr-inBuf+1)); // we must avoid the +1 in case the array is used up
return core::stringc(inBuf, (u32)(ptr-inBuf+((ptr < bufEnd) ? 1 : 0)));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment