From d01ae5cf25433bef452c8b9ff0aa0ae796b966a0 Mon Sep 17 00:00:00 2001 From: Stephen A Pohl Date: Wed, 4 May 2022 13:54:20 +0000 Subject: [XPCOM] Improve the conversion of line breaks. Fix an off-by-one error in CRLF checking. --- xpcom/io/nsLinebreakConverter.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xpcom/io/nsLinebreakConverter.cpp b/xpcom/io/nsLinebreakConverter.cpp index 62bcb54e23..a7c99d3f16 100644 --- a/xpcom/io/nsLinebreakConverter.cpp +++ b/xpcom/io/nsLinebreakConverter.cpp @@ -217,7 +217,7 @@ ConvertUnknownBreaks(const T* aInSrc, int32_t& aIoLen, const char* aDestBreak) while (src < srcEnd) { if (*src == nsCRT::CR) { - if (src < srcEnd && src[1] == nsCRT::LF) { + if (src + 1< srcEnd && src[1] == nsCRT::LF) { // CRLF finalLen += destBreakLen; src++; @@ -246,7 +246,7 @@ ConvertUnknownBreaks(const T* aInSrc, int32_t& aIoLen, const char* aDestBreak) while (src < srcEnd) { if (*src == nsCRT::CR) { - if (src < srcEnd && src[1] == nsCRT::LF) { + if (src + 1 < srcEnd && src[1] == nsCRT::LF) { // CRLF AppendLinebreak(dst, aDestBreak); src++; -- cgit v1.2.3