Bug 458158 - Crash [@ nsJAR::Open] when passing null argument to open method of zip-reader, r+sr=cbiesinger and r=jwalden+bmo

This commit is contained in:
Martijn Wargers 2009-01-22 16:12:00 +01:00
parent 36b666091c
commit 3aeca987aa
2 changed files with 12 additions and 0 deletions

View File

@ -168,6 +168,7 @@ nsrefcnt nsJAR::Release(void)
NS_IMETHODIMP NS_IMETHODIMP
nsJAR::Open(nsIFile* zipFile) nsJAR::Open(nsIFile* zipFile)
{ {
NS_ENSURE_ARG_POINTER(zipFile);
if (mLock) return NS_ERROR_FAILURE; // Already open! if (mLock) return NS_ERROR_FAILURE; // Already open!
mZipFile = zipFile; mZipFile = zipFile;

View File

@ -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
}
}