Closed Bug 167803 Opened 22 years ago Closed 22 years ago

Null pointer check for mContentTreeOwner in nsXULWindow::LoadWindowClassFromXUL

Categories

(Core :: XUL, defect)

x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: srilatha, Assigned: srilatha)

Details

Attachments

(1 file, 1 obsolete file)

We need to check if mContentTreeOwner is null in 
nsXULWindow::LoadWindowClassFromXUL before dereferencing it. There is crash 
because mContentTreeOwner is null. See bugscape bug 19655
http://bugscape.netscape.com/show_bug.cgi?id=19655
Attached patch proposed patch (obsolete) — Splinter Review
ccing danm and dougt for reviews.
Status: NEW → ASSIGNED
Comment on attachment 98627 [details] [diff] [review]
proposed patch

It looks to me that this usually doesn't crash because mContentTreeOwner
happens to have already been created for us by a quirk in one (of several)
paths in the window creation code. I think we want an active content tree owner
a little earlier on. I'd rather see:

Index: nsXULWindow.cpp
===================================================================
RCS file: /cvsroot/mozilla/xpfe/appshell/src/nsXULWindow.cpp,v
retrieving revision 1.117
diff -u -r1.117 nsXULWindow.cpp
--- nsXULWindow.cpp	7 Sep 2002 17:13:06 -0000	1.117
+++ nsXULWindow.cpp	10 Sep 2002 23:42:33 -0000
@@ -798,8 +798,9 @@
 {
   mChromeLoaded = PR_TRUE;

-  if(mContentTreeOwner)
-    mContentTreeOwner->ApplyChromeFlags();
+  NS_ENSURE_SUCCESS(EnsureContentTreeOwner(), NS_ERROR_FAILURE);
+
+  mContentTreeOwner->ApplyChromeFlags();

   LoadTitleFromXUL();
   LoadWindowClassFromXUL();

so that in the case where LoadWindowClassFromXUL is having problems we won't
skip applying the chromeflags, either.

But either is useful and will solve your problem. r=me.
Attachment #98627 - Flags: review+
Attached patch updated patchSplinter Review
since either one of the changes works for me, updated the patch so that we have
a better solution suggested by Dan.
Comment on attachment 98753 [details] [diff] [review]
updated patch

copying the r=danm from the previous patch
Attachment #98753 - Flags: review+
Attachment #98627 - Attachment is obsolete: true
Comment on attachment 98753 [details] [diff] [review]
updated patch

sr=alecf
Attachment #98753 - Flags: superreview+
should we be adding an NS_ASSERTION() since this sounds like it only occurs in a
very specific case, that may be generating a strange path through the window
creation code?
Alec, I am not sure I understand your comment completely. Do you mean we should
be using NS_ASSERTION instead of NS_ENSURE_SUCCESS?
Related changes landed on the trunk. 

Marking Fixed.
Status: ASSIGNED → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: