Closed Bug 323156 Opened 19 years ago Closed 19 years ago

XPCDispConvert::JSArrayToCOMArray does not convert empty arrays correctly

Categories

(Core :: XPConnect, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: gdavis, Assigned: gdavis)

Details

Attachments

(1 file)

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8) Gecko/20051111 Firefox/1.5 Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8) Gecko/20051111 Firefox/1.5 If a the JS array is empty, SafeArrayCreateVector() is not called. After the for loop that would call SafeArrayCreateVector() (if there were any elements in the array), the parray member of the returned VARIANT is blindly set to nsnull. When this VARIANT is passed into IDispatch::Invoke(), the COM framework throws an exception. Reproducible: Always Steps to Reproduce: 1. Create a COM component with a method that has a SAFEARRAY* parameter. 2. Create that component in JavaScript using GeckoActiveXObject. 3. Call the method on the component passing an empty JavaScript array as the parameter that's of type SAFEARRAY*. Actual Results: An exception is thrown. Expected Results: No exception should be thrown, but the empty array should be passed to the COM component's method. When there are no elements in the array, SafeArrayCreateVector() should be called with a length of zero. The result of this call should be then placed in the parray member of the VARIANT struct that is returned.
Attachment #208273 - Flags: superreview?(jst)
Attachment #208273 - Flags: review?(dbradley)
Comment on attachment 208273 [details] [diff] [review] Patch accounting for empty JS array r=dbradley Good catch.
Attachment #208273 - Flags: review?(dbradley) → review+
Comment on attachment 208273 [details] [diff] [review] Patch accounting for empty JS array sr=jst
Attachment #208273 - Flags: superreview?(jst) → superreview+
Assignee: dbradley → gdavis
Status: UNCONFIRMED → NEW
Ever confirmed: true
OS: Windows XP → All
Hardware: PC → All
Attachment #208273 - Flags: approval1.8.0.1?
gdavis: it is too late for 1.8.0.1. try 1.8.0.2 instead.
Attachment #208273 - Flags: approval1.8.0.1? → approval1.8.0.2?
Fix checked in on the trunk. FIXED.
Status: NEW → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
Comment on attachment 208273 [details] [diff] [review] Patch accounting for empty JS array Maybe for 1.8 branch (Firefox 2), not 1.8.0.x
Attachment #208273 - Flags: approval1.8.0.2?
Attachment #208273 - Flags: approval1.8.0.2-
Attachment #208273 - Flags: approval-branch-1.8.1?(jst)
Attachment #208273 - Flags: approval-branch-1.8.1?(jst) → approval-branch-1.8.1+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: