Fixing bug 488423. Don't pass 0 as the size to PR_CALLOC(). Patch by Shailen <shailen.n.jain@gmail.com>, r+sr=jst@mozilla.org
git-svn-id: svn://10.0.0.236/trunk@259921 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
e893af8fb3
commit
81f2385a1f
@ -3894,15 +3894,17 @@ protected:
|
|||||||
nsJSArgArray::nsJSArgArray(JSContext *aContext, PRUint32 argc, jsval *argv,
|
nsJSArgArray::nsJSArgArray(JSContext *aContext, PRUint32 argc, jsval *argv,
|
||||||
nsresult *prv) :
|
nsresult *prv) :
|
||||||
mContext(aContext),
|
mContext(aContext),
|
||||||
mArgv(argv),
|
mArgv(nsnull),
|
||||||
mArgc(argc)
|
mArgc(argc)
|
||||||
{
|
{
|
||||||
// copy the array - we don't know its lifetime, and ours is tied to xpcom
|
// copy the array - we don't know its lifetime, and ours is tied to xpcom
|
||||||
// refcounting. Alloc zero'd array so cleanup etc is safe.
|
// refcounting. Alloc zero'd array so cleanup etc is safe.
|
||||||
mArgv = (jsval *) PR_CALLOC(argc * sizeof(jsval));
|
if (argc) {
|
||||||
if (!mArgv) {
|
mArgv = (jsval *) PR_CALLOC(argc * sizeof(jsval));
|
||||||
*prv = NS_ERROR_OUT_OF_MEMORY;
|
if (!mArgv) {
|
||||||
return;
|
*prv = NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Callers are allowed to pass in a null argv even for argc > 0. They can
|
// Callers are allowed to pass in a null argv even for argc > 0. They can
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user