From 48f67d5e5a94ae73ad63e270ba1f7ddf6d6e3e8b Mon Sep 17 00:00:00 2001 From: "cmanske%netscape.com" Date: Sat, 15 Apr 2000 01:57:16 +0000 Subject: [PATCH] Fix null pointer bugs (35785 and nonfiled), fixes editor bug 35885. r=evaughan --- layout/xul/base/src/nsMenuFrame.cpp | 2 ++ layout/xul/base/src/nsTempleLayout.cpp | 29 +++++++++++++------------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/layout/xul/base/src/nsMenuFrame.cpp b/layout/xul/base/src/nsMenuFrame.cpp index 4da2c985854e..46c943372e3a 100644 --- a/layout/xul/base/src/nsMenuFrame.cpp +++ b/layout/xul/base/src/nsMenuFrame.cpp @@ -1477,6 +1477,8 @@ nsMenuFrame::GetPrefSize(nsBoxLayoutState& aState, nsSize& aSize) if (!frame) { MarkAsGenerated(); frame = mPopupFrames.FirstChild(); + // No child - just return + if (!frame) return NS_OK; } nsIBox* ibox = nsnull; diff --git a/layout/xul/base/src/nsTempleLayout.cpp b/layout/xul/base/src/nsTempleLayout.cpp index 51ea418c120c..5a3f32bb35ee 100644 --- a/layout/xul/base/src/nsTempleLayout.cpp +++ b/layout/xul/base/src/nsTempleLayout.cpp @@ -147,21 +147,22 @@ nsTempleLayout::BuildBoxSizeList(nsIBox* aBox, nsBoxLayoutState& aState, nsBoxSi while(box) { nsIMonument* monument = nsnull; box->GetLayoutManager(getter_AddRefs(layout)); - layout->QueryInterface(NS_GET_IID(nsIMonument), (void**)&monument); - - if (monument) - monument->BuildBoxSizeList(box, aState, first, last); - else { - nsMonumentLayout::BuildBoxSizeList(box, aState, first, last); - first->bogus = PR_TRUE; + + if (layout) { + layout->QueryInterface(NS_GET_IID(nsIMonument), (void**)&monument); + if (monument) + monument->BuildBoxSizeList(box, aState, first, last); + else { + nsMonumentLayout::BuildBoxSizeList(box, aState, first, last); + first->bogus = PR_TRUE; + } + + if (count == 0) + aFirst = first; + else + (aLast)->next = first; + aLast = last; } - - if (count == 0) - aFirst = first; - else - (aLast)->next = first; - - aLast = last; box->GetNextBox(&box); count++;