XPCOM method recieves null pointer instead of string when undefined or null was passed

VERIFIED INVALID

Status

()

--
critical
VERIFIED INVALID
11 years ago
7 years ago

People

(Reporter: crazy-eye-bugzilla, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

11 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.9b5) Gecko/2008032620 Firefox/3.0b5

XPCOM component expecting string as [in] parameter recieves null pointer when undefined/null was passed from JavaScript. It will cause crash if component tries to read this string without checking.


Reproducible: Always

Steps to Reproduce:
1. Use XPCOM component with method like this:
   XPIDL: void SomeMethod(in string inputvar)
   C++: NS_IMETHODIMP SomeComponent::SomeMethod(const char *inputvar)
2. If corresponding interface is saved in obj use
obj.SomeMethod(undefined);    or
obj.SomeMethod(null);

Actual Results:  
In C++ code inputvar == NULL


Expected Results:  
1. Some exception (maybe, with NS_ERROR_ILLEGAL_VALUE code) should be thrown by XPConnct itself without call to actual implementation OR
2. Empty C++ string("") should be passed to implementation as typecast of undefined/null

Comment 1

11 years ago
This is by design.

Possible workaround: use AString/ACString/AUTF8String
Status: UNCONFIRMED → RESOLVED
Last Resolved: 11 years ago
Resolution: --- → INVALID

Comment 2

11 years ago
this is required to enable js callers to pass null to annoying c++ impls
Status: RESOLVED → VERIFIED

Comment 3

7 years ago
Sorry forgot mention base OS

Its Windows XP SP2

Comment 4

7 years ago
Sorry forgot mention base OS -- Windows XP SP2
You need to log in before you can comment on or make changes to this bug.