Fix off-by-one error in conversion pointers. Bug 801681, r=emk
authorSimon Montagu <smontagu@smontagu.org>
Thu, 18 Oct 2012 16:35:04 +0200
changeset 110667 38784da3792d7c078be6102b8ba684884e5153ff
parent 110666 87d06105d0baac795a78d3ca814e6715a2fb3cd3
child 110668 199e231bfa7f663382ab171cee9620ad5021ada8
push id23708
push userryanvm@gmail.com
push dateFri, 19 Oct 2012 01:28:59 +0000
treeherdermozilla-central@fd5556088388 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemk
bugs801681
milestone19.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Fix off-by-one error in conversion pointers. Bug 801681, r=emk
intl/uconv/ucvcn/nsHZToUnicode.cpp
--- a/intl/uconv/ucvcn/nsHZToUnicode.cpp
+++ b/intl/uconv/ucvcn/nsHZToUnicode.cpp
@@ -137,20 +137,21 @@ NS_IMETHODIMP nsHZToUnicode::ConvertNoBu
             // on the second character.
             // 
             // N.B. For compatibility with other implementations, we treat '~\n'
             // as an illegal sequence even though RFC1843 permits it, and for
             // the same reason we pass through control characters including '\n'
             // and ' ' even in GB mode.
             if (srcByte > 0x20 || HZ_ENCODING_STATE == HZ_STATE_ASCII) {
               *aDest++ = UCS2_NO_MAPPING;
+              iDestlen++;
             }
             aSrc--;
             (*aSrcLength)--;
-            iDestlen++;
+            i--;
             break;
         }
       } else if (HZ_ENCODING_STATE == HZ_STATE_GB) {
         *aDest++ = (UINT8_IN_RANGE(0x21, oddByte, 0x7E) &&
                     UINT8_IN_RANGE(0x21, srcByte, 0x7E)) ?
                      mUtil.GBKCharToUnicode(oddByte|0x80, srcByte|0x80) :
                      UCS2_NO_MAPPING;
         mRunLength++;