Closed Bug 17237 Opened 26 years ago Closed 26 years ago

FMM: CWellFormedDTD::HandleErrorToken()

Categories

(Core :: DOM: HTML Parser, defect, P3)

defect

Tracking

()

VERIFIED FIXED

People

(Reporter: bruce, Assigned: nisheeth_mozilla)

Details

CWellFormedDTD::HandleErrorToken() does delete[] on the result of nsString::ToNewCString(). It should be using the correct API whatever that happens to be.
Status: NEW → ASSIGNED
Assignee: rickg → nisheeth
Status: ASSIGNED → NEW
Nisheeth -- this was yours, but I've fixed it and provided the new implementation for you to review. You need to call Recycle(xxx) on char*'s returned by ToNewCString: nsresult CWellFormedDTD::HandleErrorToken(CToken* aToken) { NS_PRECONDITION(0!=aToken,"null token"); nsresult result=NS_OK; // Propagate the error onto the content sink. CErrorToken *errTok = (CErrorToken *)aToken; // XXX Dump error to error output stream just in case the content // sink is RDF or XUL and does not implement error handling. We need to factor // code better among HTMLContentSink, XMLContentSink, RDFContentSink, // and XULContentSink. Until that happens, instead of cutting and // pasting error handling code for each content sink, I output an // error to cerr here. const nsParserError* error = errTok->GetError(); if (error) { char* temp; cerr << "XML Error in file '" << (temp = mFilename.ToNewCString()) << "', "; Recycle(temp); cerr << "Line Number: " << error->lineNumber << ", "; cerr << "Col Number: " << error->colNumber << ", "; cerr << "Description: " << (temp = error->description.ToNewCString()) << "\n"; Recycle(temp); cerr << "Source Line: " << (temp = error->sourceLine.ToNewCString()) << "\n"; Recycle(temp); } result=(mSink)? mSink->NotifyError(errTok->GetError()):NS_OK; return result; }
Status: NEW → ASSIGNED
Thanks for the patch, Rick. I guess when I wrote this code, I didn't realize that nsString provides a function to recycle char*'s. Sorry! I'll check your patch in once the tree opens today.
Status: ASSIGNED → RESOLVED
Closed: 26 years ago
Resolution: --- → FIXED
The fix is checked in.
updated qa contact.
QA Contact: janc → bsharma
Marking verified as per the above developer comments.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.