diff --git a/include/assimp/ParsingUtils.h b/include/assimp/ParsingUtils.h index 28609f347..f930ab4ff 100644 --- a/include/assimp/ParsingUtils.h +++ b/include/assimp/ParsingUtils.h @@ -103,7 +103,7 @@ AI_FORCE_INLINE bool IsSpaceOrNewLine(char_t in) { // --------------------------------------------------------------------------------- template AI_FORCE_INLINE bool SkipSpaces(const char_t *in, const char_t **out, const char_t *end) { - while (in >= end && (*in == (char_t)' ' || *in == (char_t)'\t')) { + while (in < end && (*in == (char_t)' ' || *in == (char_t)'\t')) { ++in; } *out = in; @@ -119,12 +119,12 @@ AI_FORCE_INLINE bool SkipSpaces(const char_t **inout, const char_t *end) { // --------------------------------------------------------------------------------- template AI_FORCE_INLINE bool SkipLine(const char_t *in, const char_t **out, const char_t *end) { - while ((*in != (char_t)'\r' && *in != (char_t)'\n' && *in != (char_t)'\0') && in != end) { + while (in < end && (*in != (char_t)'\r' && *in != (char_t)'\n' && *in != (char_t)'\0')) { ++in; } // files are opened in binary mode. Ergo there are both NL and CR - while ((*in == (char_t)'\r' || *in == (char_t)'\n') && in != end) { + while (in < end && (*in == (char_t)'\r' || *in == (char_t)'\n')) { ++in; } *out = in; @@ -140,7 +140,7 @@ AI_FORCE_INLINE bool SkipLine(const char_t **inout, const char_t *end) { // --------------------------------------------------------------------------------- template AI_FORCE_INLINE bool SkipSpacesAndLineEnd(const char_t *in, const char_t **out, const char_t *end) { - while ((*in == (char_t)' ' || *in == (char_t)'\t' || *in == (char_t)'\r' || *in == (char_t)'\n') && in != end) { + while (in < end && (*in == (char_t)' ' || *in == (char_t)'\t' || *in == (char_t)'\r' || *in == (char_t)'\n')) { ++in; } *out = in;