Closed Bug 71064 Opened 23 years ago Closed 23 years ago

Stream classes should have private, unimplemented copy ctor and assignment operators

Categories

(Core :: XPCOM, defect, P3)

All
Mac System 8.5
defect

Tracking

()

RESOLVED FIXED
mozilla0.9.1

People

(Reporter: sfraser_bugs, Assigned: sfraser_bugs)

Details

Attachments

(1 file)

We've had a number of bug recently (in bookmarks, and cookies) where stream 
assignments have caused bad things to happen, because of premature file closing. 
This happened because streams were being passed by value, not by reference, in a 
few places.

I think we should disallow implicit stream assignments by declaring private copy 
constructors and operator= on the various stream classes.
Does this bug block #69862, or in other words, prevents #69862 to be landed again.
No. Fixing this bug would make it a compile-time error if someone passes a stream 
by value, rather than by reference. This means that you can be confident that no 
streams are erroneously copied, leading to the problems we saw before.
Cc some strong C++ folks
With this patch, we would have caught pass-by-values of streams in bookmarks and 
cookies at compile time. I've built mozilla with these changes, and the fixes for 
cookie and bookmarks. I have not yet build a commercial tree.
Good work, you can reassign it to yourself, if you want.
r/sr anyone?
Assignee: naving → sfraser
r=waterson. do you mean to check in the plevent & nsPipe2 instrumentation stuff?
sr=scc
Er, whoops. Overzealous patch. Heed only the changes in nsFileStream.h
setting to moz0.9
Target Milestone: --- → mozilla0.9
Shouldn't these classes be retired, in favor of the implementations in Necko?
They should, but there is way too much code that uses them, and their close ties 
with the venerable nsFileSpec.
Priority: -- → P3
moving to mozilla0.9.1
Target Milestone: mozilla0.9 → mozilla0.9.1
Status: NEW → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
Fix checked in.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: