diff --git a/intl/uconv/src/nsUTF8ConverterService.cpp b/intl/uconv/src/nsUTF8ConverterService.cpp index 5df103c390d..b9917f2655a 100644 --- a/intl/uconv/src/nsUTF8ConverterService.cpp +++ b/intl/uconv/src/nsUTF8ConverterService.cpp @@ -77,7 +77,7 @@ ToUTF8(const nsACString &aString, const char *aCharset, nsACString &aResult) rv = unicodeDecoder->Convert(inStr.get(), &srcLen, ustr, &dstLen); if (NS_SUCCEEDED(rv)) - CopyUTF16toUTF8(nsDependentString(ustr, dstLen), aResult); + CopyUTF16toUTF8(Substring(ustr, ustr + dstLen), aResult); return rv; } diff --git a/netwerk/mime/src/nsMIMEHeaderParamImpl.cpp b/netwerk/mime/src/nsMIMEHeaderParamImpl.cpp index 093dc567584..84b09d38ce2 100644 --- a/netwerk/mime/src/nsMIMEHeaderParamImpl.cpp +++ b/netwerk/mime/src/nsMIMEHeaderParamImpl.cpp @@ -157,6 +157,7 @@ nsMIMEHeaderParamImpl::GetParameterInternal(const char *aHeaderValue, if (str == start) return NS_ERROR_UNEXPECTED; *aResult = (char *) nsMemory::Clone(start, (str - start) + 1); + (*aResult)[str - start] = '\0'; // null-terminate NS_ENSURE_TRUE(*aResult, NS_ERROR_OUT_OF_MEMORY); return NS_OK; } @@ -589,7 +590,7 @@ void CopyRawHeader(const char *aInput, PRUint32 aLen, nsCAutoString utf8Text; if (NS_SUCCEEDED(rv) && NS_SUCCEEDED( - cvtUTF8->ConvertStringToUTF8(nsDependentCString(aInput, aLen), + cvtUTF8->ConvertStringToUTF8(Substring(aInput, aInput + aLen), aDefaultCharset, skipCheck, utf8Text))) { aOutput.Append(utf8Text); } else { // replace each octet with Unicode replacement char in UTF-8.