Fix possible overrun

- closes https://github.com/assimp/assimp/issues/3425
pull/4050/head
Kim Kulling 2021-08-27 14:04:00 +02:00 committed by GitHub
parent e5bf7f7e07
commit a45878c41a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

View File

@ -59,13 +59,16 @@ void CommentRemover::RemoveLineComments(const char* szComment,
ai_assert(nullptr != szBuffer);
ai_assert(*szComment);
const size_t len = strlen(szComment);
size_t len = strlen(szComment);
const size_t lenBuffer = strlen(szBuffer);
if (len > lenBuffer) {
len = lenBuffer;
}
while (*szBuffer) {
// skip over quotes
if (*szBuffer == '\"' || *szBuffer == '\'')
while (*szBuffer++ && *szBuffer != '\"' && *szBuffer != '\'');
if (!strncmp(szBuffer,szComment,len)) {
while (!IsLineEnd(*szBuffer))
*szBuffer++ = chReplacement;