From 3aeca987aa72953161b547cb131088a7e60144e4 Mon Sep 17 00:00:00 2001 From: Martijn Wargers Date: Thu, 22 Jan 2009 16:12:00 +0100 Subject: [PATCH] Bug 458158 - Crash [@ nsJAR::Open] when passing null argument to open method of zip-reader, r+sr=cbiesinger and r=jwalden+bmo --- modules/libjar/nsJAR.cpp | 1 + modules/libjar/test/unit/test_bug458158.js | 11 +++++++++++ 2 files changed, 12 insertions(+) create mode 100644 modules/libjar/test/unit/test_bug458158.js diff --git a/modules/libjar/nsJAR.cpp b/modules/libjar/nsJAR.cpp index 15f84f7bb95..c408b3769e7 100644 --- a/modules/libjar/nsJAR.cpp +++ b/modules/libjar/nsJAR.cpp @@ -168,6 +168,7 @@ nsrefcnt nsJAR::Release(void) NS_IMETHODIMP nsJAR::Open(nsIFile* zipFile) { + NS_ENSURE_ARG_POINTER(zipFile); if (mLock) return NS_ERROR_FAILURE; // Already open! mZipFile = zipFile; diff --git a/modules/libjar/test/unit/test_bug458158.js b/modules/libjar/test/unit/test_bug458158.js new file mode 100644 index 00000000000..58271233727 --- /dev/null +++ b/modules/libjar/test/unit/test_bug458158.js @@ -0,0 +1,11 @@ +function run_test() { + var zReader = Components.classes["@mozilla.org/libjar/zip-reader;1"] + .createInstance(Components.interfaces.nsIZipReader); + try { + zReader.open(null); + do_throw("Shouldn't get here!"); + } catch (e if (e instanceof Components.interfaces.nsIException && + e.result == Components.results.NS_ERROR_NULL_POINTER)) { + // do nothing, this test passes + } +}