Closed Bug 330030 Opened 19 years ago Closed 19 years ago

crash (@ nsConverterOutputStream::Flush) if init() did not succeed

Categories

(Core :: Internationalization, defect)

defect
Not set
critical

Tracking

()

RESOLVED FIXED

People

(Reporter: asqueella, Assigned: asqueella)

Details

(Keywords: crash, fixed1.8.1)

Attachments

(1 file)

Running the following crashes firefox trunk: var file = Components.classes['@mozilla.org/file/directory_service;1'] .getService(Components.interfaces.nsIProperties) .get('ProfD', Components.interfaces.nsIFile); file.append("test"); var os = Components.classes["@mozilla.org/network/file-output-stream;1"] .createInstance(Components.interfaces.nsIFileOutputStream); os.init(file, 0x04 | 0x08 | 0x20, 420, 0); var cos = Components.classes["@mozilla.org/intl/converter-output-stream;1"] .createInstance(Components.interfaces.nsIConverterOutputStream); try { cos.init(os, "klkl", 0, 0x0000);//throws } catch(e) { } cos.close();//crashes uconv.dll!nsConverterOutputStream::Flush() Line 145 + 0x29 bytes C++ uconv.dll!nsConverterOutputStream::Close() Line 169 + 0xe bytes C++ xpcom_core.dll!XPTC_InvokeByIndex(...) Line 102 C++
Attached patch patchSplinter Review
The destructor part isn't necessary to fix the crash, but Close() is enough there, since it both checks mOutStream and calls Flush().
Assignee: smontagu → asqueella
Status: NEW → ASSIGNED
Attachment #214666 - Flags: superreview?(darin)
Attachment #214666 - Flags: review?(cbiesinger)
Attachment #214666 - Flags: review?(cbiesinger) → review+
Comment on attachment 214666 [details] [diff] [review] patch In general, it's good if an initialization function leaves the object unchanged when it fails. While this change doesn't do that, it seems okay. sr=darin
Attachment #214666 - Flags: superreview?(darin) → superreview+
Whiteboard: [checkin needed]
Attachment #214666 - Flags: approval-branch-1.8.1?(darin)
Checking in intl/uconv/src/nsConverterOutputStream.cpp; /cvsroot/mozilla/intl/uconv/src/nsConverterOutputStream.cpp,v <-- nsConverterOutputStream.cpp new revision: 1.3; previous revision: 1.2 done
Status: ASSIGNED → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
Whiteboard: [checkin needed]
Attachment #214666 - Flags: approval-branch-1.8.1?(darin) → approval-branch-1.8.1+
checked in on MOZILLA_1_8_BRANCH Checking in intl/uconv/src/nsConverterOutputStream.cpp; /cvsroot/mozilla/intl/uconv/src/nsConverterOutputStream.cpp,v <-- nsConverterOutputStream.cpp new revision: 1.1.4.2; previous revision: 1.1.4.1 done
Keywords: fixed1.8.1
Severity: normal → critical
OS: Windows XP → All
Hardware: PC → All
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: