Crash printing document with no title

VERIFIED FIXED

Status

()

Core
Printing: Output
--
critical
VERIFIED FIXED
17 years ago
17 years ago

People

(Reporter: Hixie (not reading bugmail), Assigned: dcone (gone))

Tracking

Trunk
x86
Windows 2000
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(URL)

Attachments

(1 attachment)

(Reporter)

Description

17 years ago
mozilla/layout/base/src/nsDocumentViewer.cpp around line 1497 does:

        // get the document title
        const nsString* docTitle = mDocument->GetDocumentTitle();
        PRUnichar * docStr = docTitle->ToNewUnicode();
        printService->SetTitle(docStr);
        nsMemory::Free(docStr);

This crashes if mDocument->GetDocumentTitle() returns NULL, as it does when
printing a picture (or probably an XML file, untested).

This requires at least a null pointer check.

STEPS TO REPRODUCE
   1. Go to an image, for example:
 http://www.dilbert.com/comics/dilbert/archive/images/dilbert20010121044118.gif
   2. Print.

ACTUAL RESULTS
   1. Laugh at picture.
   2. Cry at crash.

EXPECTED RESULTS
   1. Laugh at picture.
   2. Collect printout and stick it to your cube wall.
   3. Watch other people laugh at picture.

This bug was introduced by Rod's recent checkin, so assigning direct to him.

Comment 1

17 years ago
reassigning to dcone he has a fix in his tree for this, I have already checked 
in the fix on the embed branch for this
Assignee: rods → dcone
(Assignee)

Comment 2

17 years ago
Fixed
Status: NEW → RESOLVED
Last Resolved: 17 years ago
Resolution: --- → FIXED

Comment 3

17 years ago
verified in 2/26 build.
Status: RESOLVED → VERIFIED

Comment 4

17 years ago
The fix for this bug corrects the crash, but introduces other behaviour which is
not ideal. Specifically, there are bugs 80799 and 81848 which are mis-listed as
duplicates of  71976 but aren't... With this fix, a document with no title will
print with the title of the previous printed page.
The correct fix for this is actually the fix for 71976, which gets rid of the
unprotected check of the title pointer.
To fix the stale title, I propose one of two patches. Either allow the title to
be null in the print properties, or set it to the empty string if it is null...
I am testing patches as I type this...
Should I enter this as a new bug, or is one of the bugs mentioned here more
appropriate?

Comment 5

17 years ago
Created attachment 39065 [details] [diff] [review]
Fixes printing of title for document with no title

Comment 6

17 years ago
I filed a new bug for this, Bug: 86558 and included my patch
You need to log in before you can comment on or make changes to this bug.