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:
jst%mozilla.org 2010-03-08 20:21:18 +00:00
parent e893af8fb3
commit 81f2385a1f

View File

@ -3894,16 +3894,18 @@ 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.
if (argc) {
mArgv = (jsval *) PR_CALLOC(argc * sizeof(jsval)); mArgv = (jsval *) PR_CALLOC(argc * sizeof(jsval));
if (!mArgv) { if (!mArgv) {
*prv = NS_ERROR_OUT_OF_MEMORY; *prv = NS_ERROR_OUT_OF_MEMORY;
return; 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
// then use GetArgs to initialize the values. // then use GetArgs to initialize the values.