Bug 1359369 - prevent null pointer dereference in NS_GetIsDocumentChannel. r?valentin draft
authorAndi-Bogdan Postelnicu <bpostelnicu@mozilla.com>
Tue, 25 Apr 2017 14:38:03 +0300
changeset 567675 71cb618cb38e2920fc9645f392bd59454e2e8838
parent 567507 85932a5027c024900bb0e58cdbc52ecf9a32e1f5
child 625733 45bcc65bdc0108b259804e3e9cfe23d560c8a50c
push id55661
push userbmo:bpostelnicu@mozilla.com
push dateTue, 25 Apr 2017 11:38:33 +0000
reviewersvalentin
bugs1359369
milestone55.0a1
Bug 1359369 - prevent null pointer dereference in NS_GetIsDocumentChannel. r?valentin MozReview-Commit-ID: I1iu2miXmjZ
netwerk/base/nsNetUtil.cpp
--- a/netwerk/base/nsNetUtil.cpp
+++ b/netwerk/base/nsNetUtil.cpp
@@ -361,20 +361,20 @@ NS_NewChannel(nsIChannel           **out
 nsresult
 NS_GetIsDocumentChannel(nsIChannel * aChannel, bool *aIsDocument)
 {
   // Check if this channel is going to be used to create a document. If it has
   // LOAD_DOCUMENT_URI set it is trivially creating a document. If
   // LOAD_HTML_OBJECT_DATA is set it may or may not be used to create a
   // document, depending on its MIME type.
 
-  *aIsDocument = false;
   if (!aChannel || !aIsDocument) {
       return NS_ERROR_NULL_POINTER;
   }
+  *aIsDocument = false;
   nsLoadFlags loadFlags;
   nsresult rv = aChannel->GetLoadFlags(&loadFlags);
   if (NS_FAILED(rv)) {
       return rv;
   }
   if (loadFlags & nsIChannel::LOAD_DOCUMENT_URI) {
       *aIsDocument = true;
       return NS_OK;