From 390dd19a054db34b03c8390d5af2f204df393c6f Mon Sep 17 00:00:00 2001 From: "jst%mozilla.jstenback.com" Date: Tue, 31 Jan 2006 01:47:01 +0000 Subject: [PATCH] Landing fix for bug 323156. XPCDispConvert::JSArrayToCOMArray does not convert empty arrays correctly. Patch by gdavis@nsisoftware.com, r=dbradley@gmail.com, sr=jst@mozilla.org --- js/src/xpconnect/src/XPCDispConvert.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/js/src/xpconnect/src/XPCDispConvert.cpp b/js/src/xpconnect/src/XPCDispConvert.cpp index 53bcc6c5d8fc..e1795ad66c59 100644 --- a/js/src/xpconnect/src/XPCDispConvert.cpp +++ b/js/src/xpconnect/src/XPCDispConvert.cpp @@ -131,7 +131,19 @@ JSBool XPCDispConvert::JSArrayToCOMArray(XPCCallContext& ccx, JSObject *obj, ++varArray; } } - SafeArrayUnaccessData(array); + if(!array) + { + array = SafeArrayCreateVector(VT_VARIANT, 0, 0); + if(!array) + { + err = NS_ERROR_OUT_OF_MEMORY; + return JS_FALSE; + } + } + else + { + SafeArrayUnaccessData(array); + } var.vt = VT_ARRAY | VT_VARIANT; var.parray = array; return JS_TRUE;