Skip to content

Commit

Permalink
fix possible infinite loop when transcoding from/to UTF-8
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Feb 14, 2019
1 parent ad51185 commit 1a68b75
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Base/XMLTools.h
Expand Up @@ -157,6 +157,10 @@ inline StrXUTF8::StrXUTF8(const XMLCh* const toTranscode)
str.append((const char*)outBuff, outputLength);
offset += eaten;
inputLength -= eaten;

// Bail out if nothing more was produced
if (outputLength == 0)
break;
}
}

Expand Down Expand Up @@ -274,6 +278,10 @@ inline XUTF8Str::XUTF8Str(const char* const fromTranscode)
str.append(outBuff, outputLength);
offset += eaten;
inputLength -= eaten;

// Bail out if nothing more was produced
if (outputLength == 0)
break;
}

delete[] charSizes;
Expand Down

0 comments on commit 1a68b75

Please sign in to comment.