Permalink
Browse files

Bug 668906 - Do not call openUnsharedDatabase with a null file (r=sdw…

…ilsh)

--HG--
extra : rebase_source : fbd0febc77e9972d10409ce09c73759f7d156ad1
  • Loading branch information...
hotsphink committed Jul 1, 2011
1 parent f274cd8 commit 4ae46d0025b036d302efa0c96e0689986a327ad8
@@ -477,6 +477,8 @@ NS_IMETHODIMP
Service::OpenUnsharedDatabase(nsIFile *aDatabaseFile,
mozIStorageConnection **_connection)
{
+ NS_ENSURE_ARG(aDatabaseFile);
+
#ifdef NS_FUNCTION_TIMER
nsCString leafname;
(void)aDatabaseFile->GetNativeLeafName(leafname);
@@ -64,6 +64,18 @@ function test_openDatabase_null_file()
}
}
+function test_openUnsharedDatabase_null_file()
+{
+ try {
+ getService().openUnsharedDatabase(null);
+ do_throw("We should not get here!");
+ } catch (e) {
+ print(e);
+ print("e.result is " + e.result);
+ do_check_eq(Cr.NS_ERROR_INVALID_ARG, e.result);
+ }
+}
+
function test_openDatabase_file_DNE()
{
// the file should be created after calling
@@ -131,6 +143,7 @@ function test_backup_new_folder()
var tests = [
test_openSpecialDatabase_invalid_arg,
test_openDatabase_null_file,
+ test_openUnsharedDatabase_null_file,
test_openDatabase_file_DNE,
test_openDatabase_file_exists,
test_corrupt_db_throws_with_openDatabase,
@@ -17,7 +17,8 @@ function run_test() {
let file = do_get_file("default.sqlite");
file.copyToFollowingLinks(gProfD, "places.sqlite");
- file = gProfD.clone().append("places.sqlite");
+ file = gProfD.clone();
+ file.append("places.sqlite");
// Create some unique stuff to check later.
let db = Services.storage.openUnsharedDatabase(file);

0 comments on commit 4ae46d0

Please sign in to comment.