Closed Bug 21591 Opened 25 years ago Closed 25 years ago

nsIFileSpec::FromFileSpec assumes incoming pointer is nsIFileSpecImpl

Categories

(Core :: XPCOM, defect, P3)

defect

Tracking

()

RESOLVED FIXED

People

(Reporter: tonyr, Assigned: dougt)

References

Details

Create a nsIFileSpecWithUI, use it to select a file, then set a different nsIFileSpec with the new file using FromFileSpec( nsIFileSpec *). FromFileSpec crashes in this case. It assumes that the incoming nsIFileSpec is actually an nsFileSpecImpl pointer when in fact it could be any implementation of nsIFileSpec (in this case nsFileSpecWithUIImpl! This assumption occurs in other places in nsFileSpecImpl as well.
yet another problem with nsFileSpec. Moving this to m14. This will be fixed by nsIFile. Tony, if you want to send me a diff, I will check it in. Otherwise, I think that we should just try to get rid of nsFileSpec.
Target Milestone: M14
Depends on: 22047
will be fixed by 22047
here's the diff from my fix for this one: cvs diff nsFileSpecImpl.cpp (in directory O:\mozilla\xpcom\io\) Index: nsFileSpecImpl.cpp =================================================================== RCS file: /cvsroot/mozilla/xpcom/io/nsFileSpecImpl.cpp,v retrieving revision 3.31 diff -r3.31 nsFileSpecImpl.cpp 84,85c84,92 < mFileSpec = FILESPEC(original); < return mFileSpec.Error(); --- > if (original) { > nsresult rv = ((nsIFileSpec *)original)->GetFileSpec( &mFileSpec); > if (NS_SUCCEEDED( rv)) > return mFileSpec.Error(); > else > return( rv); > } > else > return( NS_ERROR_FAILURE);
Status: NEW → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
I will check this in once the NSIFILE_01062000_BRANCH branch lands. Thanks for your diff.
You need to log in before you can comment on or make changes to this bug.