Closed Bug 245544 Opened 20 years ago Closed 16 years ago

nsBaseFilePicker::AppendFilters does not check for failure of getService

Categories

(Core :: XUL, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla1.9.2a1

People

(Reporter: timeless, Assigned: timeless)

References

()

Details

(Keywords: crash)

Attachments

(1 file, 1 obsolete file)

do_GetService can fail, when it does, you have a nice null pointer. when you use that null pointer, you 
get a nice crash.
Attached patch Possible patch by timelyx (obsolete) — Splinter Review
Testcase:

edit components/compreg.dat
look for a line like:
@mozilla.org/intl/stringbundle;1,{d85a17c1-aa7c-11d2-9b8c-00805f8a16d9}
remove it
save the file
make it readonly
run xpcshell
fp=Components.classes["@mozilla.org/filepicker;1"].createInstance(Components.interfaces.nsIFilePicker);

fp.appendFilters(1);

w/o the patch, you should crash

w/ the patch, you shouldn't : 

js>
fp=Components.classes["@mozilla.org/filepicker;1"].createInstance(Components
.interfaces.nsIFilePicker);
[xpconnect wrapped nsIFilePicker @ 0x11efa58]
js> fp.appendFilters(1);
WARNING: NS_ENSURE_TRUE(NS_SUCCEEDED(rv)) failed, file
c:/Docume~1/cchantepie.INTRANET/mozilla/widget/src/xpwidgets/nsBaseFilePicker.cpp,
line 122
uncaught exception: [Exception... "Component returned failure code: 0x80040154
(NS_ERROR_FACTORY_NOT_REGISTERED) [nsIFilePicker.appendFilters]"  nsresult:
"0x80
040154 (NS_ERROR_FACTORY_NOT_REGISTERED)"  location: "JS frame :: typein ::
<TOP_LEVEL> :: line 2"	data: no]
js> nsStringStats
 => mAllocCount: 1493
 => mReallocCount: 0
 => mFreeCount: 1423
 => mShareCount: 5345
 => mAdoptCount: 661
 => mAdoptFreeCount: 661
Attachment #150005 - Flags: review?(neil.parkwaycc.co.uk)
Attachment #150005 - Flags: review?(neil.parkwaycc.co.uk) → review+
Get this one fixed, we shouldn't have more than a few thousand more...
Attachment #150005 - Attachment is obsolete: true
Attachment #364846 - Flags: superreview?(neil)
OS: Mac OS X → All
QA Contact: jrgmorrison → xptoolkit.widgets
Hardware: PowerPC → All
Whiteboard: [needs sr neil]
Target Milestone: --- → mozilla1.9.2a1
Attachment #364846 - Flags: superreview?(neil) → superreview+
Whiteboard: [needs sr neil]
http://hg.mozilla.org/mozilla-central/rev/12f75d46323f
Status: NEW → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: