From 7a24eb76d8a9623235539b315bb358c2dc4c2fc6 Mon Sep 17 00:00:00 2001 From: "timeless%mozdev.org" Date: Wed, 10 Nov 2004 21:58:00 +0000 Subject: [PATCH] Bug 207309 nsMemoryImpl::Alloc of 0: 'size' in jsdValue::GetProperties r=shaver sr=shaver --- js/jsd/jsd_xpc.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/js/jsd/jsd_xpc.cpp b/js/jsd/jsd_xpc.cpp index 92f23e52462..f264aa099ab 100644 --- a/js/jsd/jsd_xpc.cpp +++ b/js/jsd/jsd_xpc.cpp @@ -2169,18 +2169,20 @@ NS_IMETHODIMP jsdValue::GetProperties (jsdIProperty ***propArray, PRUint32 *length) { ASSERT_VALID_EPHEMERAL; - if (!JSD_IsValueObject(mCx, mValue)) { - *length = 0; + PRUint32 prop_count = JSD_IsValueObject(mCx, mValue) + ? JSD_GetCountOfProperties (mCx, mValue) + : 0; + if (!prop_count) { + if (length) + *length = 0; *propArray = 0; return NS_OK; } - jsdIProperty **pa_temp; - PRUint32 prop_count = JSD_GetCountOfProperties (mCx, mValue); - - pa_temp = NS_STATIC_CAST(jsdIProperty **, - nsMemory::Alloc(sizeof (jsdIProperty *) * - prop_count)); + jsdIProperty **pa_temp = + NS_STATIC_CAST(jsdIProperty **, + nsMemory::Alloc(sizeof (jsdIProperty *) * + prop_count)); PRUint32 i = 0; JSDProperty *iter = NULL;