Bug 793311 - Crash in nsDOMFileFile::nsDOMFileFile. r=khuey
authorAndrea Marchesini <amarchesini@mozilla.com>
Tue, 25 Sep 2012 11:04:25 -0400
changeset 108134 768c8c6d3fe0652dad51124613ec94a57a8f6f7b
parent 108133 c89fff328c4c4051711207e0a6f2c6a9fdcf6b11
child 108135 2cf6a9aa2dbed622ae76a84f24af465fef80ac3c
push id82
push usershu@rfrn.org
push dateFri, 05 Oct 2012 13:20:22 +0000
reviewerskhuey
bugs793311
milestone18.0a1
Bug 793311 - Crash in nsDOMFileFile::nsDOMFileFile. r=khuey
dom/base/nsDOMWindowUtils.cpp
dom/file/test/Makefile.in
dom/file/test/test_bug_793311.html
--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -2319,16 +2319,20 @@ nsDOMWindowUtils::GetOuterWindowWithId(u
 NS_IMETHODIMP
 nsDOMWindowUtils::WrapDOMFile(nsIFile *aFile,
                               nsIDOMFile **aDOMFile)
 {
   if (!IsUniversalXPConnectCapable()) {
     return NS_ERROR_DOM_SECURITY_ERR;
   }
 
+  if (!aFile) {
+    return NS_ERROR_FAILURE;
+  }
+
   NS_ADDREF(*aDOMFile = new nsDOMFileFile(aFile));
   return NS_OK;
 }
 
 #ifdef DEBUG
 static bool
 CheckLeafLayers(Layer* aLayer, const nsIntPoint& aOffset, nsIntRegion* aCoveredRegion)
 {
--- a/dom/file/test/Makefile.in
+++ b/dom/file/test/Makefile.in
@@ -26,11 +26,12 @@ MOCHITEST_FILES = \
   test_request_readyState.html \
   test_stream_tracking.html \
   test_success_events_after_abort.html \
   test_truncate.html \
   test_write_read_data.html \
   test_workers.html \
   test_archivereader.html \
   test_archivereader_zip_in_zip.html \
+  test_bug_793311.html \
   $(NULL)
 
 include $(topsrcdir)/config/rules.mk
new file mode 100644
--- /dev/null
+++ b/dom/file/test/test_bug_793311.html
@@ -0,0 +1,28 @@
+<!--
+  Any copyright is dedicated to the Public Domain.
+  http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<html>
+<head>
+  <title>Bug 793311 Test</title>
+
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+
+</head>
+
+<body>
+  <script type="text/javascript;version=1.7">
+  SimpleTest.waitForExplicitFinish();
+
+  try {
+    SpecialPowers.DOMWindowUtils.wrapDOMFile(null);
+    ok(false, "wrapDOMFile(null) throws an exception");
+  } catch(e) {
+    ok(true, "wrapDOMFile(null) throws an exception");
+  }
+  SimpleTest.finish();
+  </script>
+</body>
+
+</html>