diff --git a/include/assimp/LineSplitter.h b/include/assimp/LineSplitter.h index 635349dc0..ef487bfc2 100644 --- a/include/assimp/LineSplitter.h +++ b/include/assimp/LineSplitter.h @@ -155,7 +155,7 @@ AI_FORCE_INLINE LineSplitter::LineSplitter(StreamReaderLE& stream, bool skip_emp mSkip_empty_lines(skip_empty_lines), mTrim(trim) { mCur.reserve(1024); - mEnd = mCur.c_str() + 1024; + mEnd = mCur.c_str() + mCur.size(); operator++(); mIdx = 0; } @@ -172,6 +172,7 @@ AI_FORCE_INLINE LineSplitter& LineSplitter::operator++() { char s; mCur.clear(); + mEnd = mCur.c_str() + mCur.size(); while (mStream.GetRemainingSize() && (s = mStream.GetI1(), 1)) { if (s == '\n' || s == '\r') { if (mSkip_empty_lines) { @@ -194,6 +195,7 @@ AI_FORCE_INLINE LineSplitter& LineSplitter::operator++() { break; } mCur += s; + mEnd = mCur.c_str() + mCur.size(); } ++mIdx; diff --git a/include/assimp/ParsingUtils.h b/include/assimp/ParsingUtils.h index f930ab4ff..20d029145 100644 --- a/include/assimp/ParsingUtils.h +++ b/include/assimp/ParsingUtils.h @@ -107,7 +107,7 @@ AI_FORCE_INLINE bool SkipSpaces(const char_t *in, const char_t **out, const char ++in; } *out = in; - return !IsLineEnd(*in); + return in < end && !IsLineEnd(*in); } // --------------------------------------------------------------------------------- @@ -128,7 +128,7 @@ AI_FORCE_INLINE bool SkipLine(const char_t *in, const char_t **out, const char_t ++in; } *out = in; - return *in != (char_t)'\0'; + return in < end && *in != (char_t)'\0'; } // --------------------------------------------------------------------------------- @@ -144,7 +144,7 @@ AI_FORCE_INLINE bool SkipSpacesAndLineEnd(const char_t *in, const char_t **out, ++in; } *out = in; - return *in != '\0'; + return in < end && *in != '\0'; } // ---------------------------------------------------------------------------------