зеркало из https://github.com/mozilla/gecko-dev.git
Fixing bug 92272. Avoid malloc(0), patch mostly by mkaply@us.ibm.com. sr=me, r=nobody (trivial fix)
This commit is contained in:
Родитель
e7ee086f77
Коммит
ce7442eb89
|
@ -2491,6 +2491,8 @@ NS_IMETHODIMP GlobalWindowImpl::Unescape(const nsAReadableString& aStr,
|
||||||
nsCOMPtr<nsIUnicodeDecoder> decoder;
|
nsCOMPtr<nsIUnicodeDecoder> decoder;
|
||||||
nsAutoString charset;
|
nsAutoString charset;
|
||||||
|
|
||||||
|
aReturn.Truncate();
|
||||||
|
|
||||||
nsCOMPtr<nsICharsetConverterManager>
|
nsCOMPtr<nsICharsetConverterManager>
|
||||||
ccm(do_GetService(kCharsetConverterManagerCID));
|
ccm(do_GetService(kCharsetConverterManagerCID));
|
||||||
NS_ENSURE_TRUE(ccm, NS_ERROR_FAILURE);
|
NS_ENSURE_TRUE(ccm, NS_ERROR_FAILURE);
|
||||||
|
@ -2516,7 +2518,7 @@ NS_IMETHODIMP GlobalWindowImpl::Unescape(const nsAReadableString& aStr,
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
// Need to copy to do the two-byte to one-byte deflation
|
// Need to copy to do the two-byte to one-byte deflation
|
||||||
char *inBuf = ToNewCString(aStr );
|
char *inBuf = ToNewCString(aStr);
|
||||||
if (!inBuf)
|
if (!inBuf)
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
|
@ -2528,7 +2530,7 @@ NS_IMETHODIMP GlobalWindowImpl::Unescape(const nsAReadableString& aStr,
|
||||||
|
|
||||||
// Get the expected length of the result string
|
// Get the expected length of the result string
|
||||||
result = decoder->GetMaxLength(src, srcLen, &maxLength);
|
result = decoder->GetMaxLength(src, srcLen, &maxLength);
|
||||||
if (NS_FAILED(result)) {
|
if (NS_FAILED(result) || !maxLength) {
|
||||||
nsMemory::Free(src);
|
nsMemory::Free(src);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче