From 51307aaffd455bc5ce7ad03fd5f0862aa53712a2 Mon Sep 17 00:00:00 2001 From: "attinasi%netscape.com" Date: Tue, 26 Sep 2000 21:00:32 +0000 Subject: [PATCH] Checking for null before deref: b=55358 r=a=buster --- layout/base/nsCSSFrameConstructor.cpp | 24 ++++++++++++++----- .../html/style/src/nsCSSFrameConstructor.cpp | 24 ++++++++++++++----- 2 files changed, 36 insertions(+), 12 deletions(-) diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 246f941368e..ce10d7d9709 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -7965,9 +7965,15 @@ FindPreviousAnonymousSibling(nsIPresShell* aPresShell, nsCOMPtr doc; aContainer->GetDocument(*getter_AddRefs(doc)); - nsCOMPtr xblDoc(do_QueryInterface(doc)); - nsCOMPtr elt(do_QueryInterface(aContainer)); - xblDoc->GetAnonymousNodes(elt, getter_AddRefs(nodeList)); + NS_ASSERTION(doc, "null document from content element in FindPreviousAnonymousSibling"); + if (doc) { + nsCOMPtr xblDoc(do_QueryInterface(doc)); + NS_ASSERTION(xblDoc, "null xblDoc for content element in FindPreviousAnonymousSibling"); + if (xblDoc) { + nsCOMPtr elt(do_QueryInterface(aContainer)); + xblDoc->GetAnonymousNodes(elt, getter_AddRefs(nodeList)); + } + } if (nodeList) { PRUint32 ctr,listLength; nsCOMPtr node; @@ -8031,9 +8037,15 @@ FindNextAnonymousSibling(nsIPresShell* aPresShell, nsCOMPtr doc; aContainer->GetDocument(*getter_AddRefs(doc)); - nsCOMPtr xblDoc(do_QueryInterface(doc)); - nsCOMPtr elt(do_QueryInterface(aContainer)); - xblDoc->GetAnonymousNodes(elt, getter_AddRefs(nodeList)); + NS_ASSERTION(doc, "null document from content element in FindNextAnonymousSibling"); + if (doc) { + nsCOMPtr xblDoc(do_QueryInterface(doc)); + NS_ASSERTION(xblDoc, "null xblDoc for content element in FindNextAnonymousSibling"); + if (xblDoc) { + nsCOMPtr elt(do_QueryInterface(aContainer)); + xblDoc->GetAnonymousNodes(elt, getter_AddRefs(nodeList)); + } + } if (nodeList) { PRUint32 ctr,listLength; nsCOMPtr node; diff --git a/layout/html/style/src/nsCSSFrameConstructor.cpp b/layout/html/style/src/nsCSSFrameConstructor.cpp index 246f941368e..ce10d7d9709 100644 --- a/layout/html/style/src/nsCSSFrameConstructor.cpp +++ b/layout/html/style/src/nsCSSFrameConstructor.cpp @@ -7965,9 +7965,15 @@ FindPreviousAnonymousSibling(nsIPresShell* aPresShell, nsCOMPtr doc; aContainer->GetDocument(*getter_AddRefs(doc)); - nsCOMPtr xblDoc(do_QueryInterface(doc)); - nsCOMPtr elt(do_QueryInterface(aContainer)); - xblDoc->GetAnonymousNodes(elt, getter_AddRefs(nodeList)); + NS_ASSERTION(doc, "null document from content element in FindPreviousAnonymousSibling"); + if (doc) { + nsCOMPtr xblDoc(do_QueryInterface(doc)); + NS_ASSERTION(xblDoc, "null xblDoc for content element in FindPreviousAnonymousSibling"); + if (xblDoc) { + nsCOMPtr elt(do_QueryInterface(aContainer)); + xblDoc->GetAnonymousNodes(elt, getter_AddRefs(nodeList)); + } + } if (nodeList) { PRUint32 ctr,listLength; nsCOMPtr node; @@ -8031,9 +8037,15 @@ FindNextAnonymousSibling(nsIPresShell* aPresShell, nsCOMPtr doc; aContainer->GetDocument(*getter_AddRefs(doc)); - nsCOMPtr xblDoc(do_QueryInterface(doc)); - nsCOMPtr elt(do_QueryInterface(aContainer)); - xblDoc->GetAnonymousNodes(elt, getter_AddRefs(nodeList)); + NS_ASSERTION(doc, "null document from content element in FindNextAnonymousSibling"); + if (doc) { + nsCOMPtr xblDoc(do_QueryInterface(doc)); + NS_ASSERTION(xblDoc, "null xblDoc for content element in FindNextAnonymousSibling"); + if (xblDoc) { + nsCOMPtr elt(do_QueryInterface(aContainer)); + xblDoc->GetAnonymousNodes(elt, getter_AddRefs(nodeList)); + } + } if (nodeList) { PRUint32 ctr,listLength; nsCOMPtr node;