Bug 485592 Fix nsTextToSubURI::UnEscapeAndConvert allocator mismatches r=smontagu sr=jag

This commit is contained in:
Neil Rashbrook 2009-05-15 11:37:59 +01:00
parent 70e2e8c94a
commit 3498009117

View File

@ -84,7 +84,7 @@ NS_IMETHODIMP nsTextToSubURI::ConvertAndEscape(
if(NS_SUCCEEDED(rv = encoder->GetMaxLength(text, ulen, &outlen)))
{
if(outlen >= 256) {
pBuf = (char*)PR_Malloc(outlen+1);
pBuf = (char*)NS_Alloc(outlen+1);
}
if(nsnull == pBuf) {
outlen = 255;
@ -105,7 +105,7 @@ NS_IMETHODIMP nsTextToSubURI::ConvertAndEscape(
}
}
if(pBuf != buf)
PR_Free(pBuf);
NS_Free(pBuf);
}
NS_RELEASE(encoder);
}
@ -123,7 +123,7 @@ NS_IMETHODIMP nsTextToSubURI::UnEscapeAndConvert(
nsresult rv = NS_OK;
// unescape the string, unescape changes the input
char *unescaped = nsCRT::strdup((char *) text);
char *unescaped = NS_strdup(text);
if (nsnull == unescaped)
return NS_ERROR_OUT_OF_MEMORY;
unescaped = nsUnescape(unescaped);
@ -140,7 +140,7 @@ NS_IMETHODIMP nsTextToSubURI::UnEscapeAndConvert(
PRInt32 len = strlen(unescaped);
PRInt32 outlen = 0;
if (NS_SUCCEEDED(rv = decoder->GetMaxLength(unescaped, len, &outlen))) {
pBuf = (PRUnichar *) PR_Malloc((outlen+1)*sizeof(PRUnichar*));
pBuf = (PRUnichar *) NS_Alloc((outlen+1)*sizeof(PRUnichar*));
if (nsnull == pBuf)
rv = NS_ERROR_OUT_OF_MEMORY;
else {
@ -149,13 +149,13 @@ NS_IMETHODIMP nsTextToSubURI::UnEscapeAndConvert(
*_retval = pBuf;
}
else
PR_Free(pBuf);
NS_Free(pBuf);
}
}
NS_RELEASE(decoder);
}
}
PR_Free(unescaped);
NS_Free(unescaped);
return rv;
}
@ -210,7 +210,7 @@ nsresult nsTextToSubURI::convertURItoUnicode(const nsAFlatCString &aCharset,
rv = unicodeDecoder->GetMaxLength(aURI.get(), srcLen, &dstLen);
NS_ENSURE_SUCCESS(rv, rv);
PRUnichar *ustr = (PRUnichar *) nsMemory::Alloc(dstLen * sizeof(PRUnichar));
PRUnichar *ustr = (PRUnichar *) NS_Alloc(dstLen * sizeof(PRUnichar));
NS_ENSURE_TRUE(ustr, NS_ERROR_OUT_OF_MEMORY);
rv = unicodeDecoder->Convert(aURI.get(), &srcLen, ustr, &dstLen);
@ -218,7 +218,7 @@ nsresult nsTextToSubURI::convertURItoUnicode(const nsAFlatCString &aCharset,
if (NS_SUCCEEDED(rv))
_retval.Assign(ustr, dstLen);
nsMemory::Free(ustr);
NS_Free(ustr);
return rv;
}