From 87f4106b24bf78ddb91bd63f7cd322f28c9ef3d0 Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 14 Feb 2019 11:06:30 +0100 Subject: [PATCH] fix possible infinite loop when transcoding from/to UTF-8 --- src/Base/XMLTools.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Base/XMLTools.h b/src/Base/XMLTools.h index 1d9c75e306..e96e9c6707 100644 --- a/src/Base/XMLTools.h +++ b/src/Base/XMLTools.h @@ -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; } } @@ -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;