Bug 555087 - Add check for exception when passing undefined parameter. r=adw
authorJeffrey Tran <tranj23@gmail.com>
Wed, 20 Jan 2016 16:37:00 +0100
changeset 318180 90bd68144f35b6122aefd9ebb5f07ead0cf9875e
parent 318179 f9b4c81ca1a0a8d8a8d82ade1dc6b6e67e009cb4
child 318181 552b9c942c011bf7aea2fccc64183ac2cc925673
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersadw
bugs555087
milestone47.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 555087 - Add check for exception when passing undefined parameter. r=adw
storage/mozStorageStatement.cpp
storage/test/unit/test_storage_statement.js
--- a/storage/mozStorageStatement.cpp
+++ b/storage/mozStorageStatement.cpp
@@ -540,16 +540,18 @@ Statement::Reset()
   mExecuting = false;
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 Statement::BindParameters(mozIStorageBindingParamsArray *aParameters)
 {
+  NS_ENSURE_ARG_POINTER(aParameters);
+
   if (!mDBStatement)
     return NS_ERROR_NOT_INITIALIZED;
 
   BindingParamsArray *array = static_cast<BindingParamsArray *>(aParameters);
   if (array->getOwner() != this)
     return NS_ERROR_UNEXPECTED;
 
   if (array->length() == 0)
--- a/storage/test/unit/test_storage_statement.js
+++ b/storage/test/unit/test_storage_statement.js
@@ -160,24 +160,35 @@ function test_failed_execute()
   catch (e) {
     do_check_eq(getOpenedDatabase().lastError, Ci.mozIStorageError.CONSTRAINT);
   }
   do_check_eq(Ci.mozIStorageStatement.MOZ_STORAGE_STATEMENT_READY, stmt.state);
   // Should succeed without needing to reset the statement manually
   stmt.finalize();
 }
 
+function test_bind_undefined()
+{
+  var stmt = createStatement("INSERT INTO test (name) VALUES ('foo')");
+  
+  expectError(Cr.NS_ERROR_ILLEGAL_VALUE,
+              () => stmt.bindParameters(undefined));
+
+  stmt.finalize();
+}
+
 var tests = [test_parameterCount_none, test_parameterCount_one,
              test_getParameterName, test_getParameterIndex_different,
              test_getParameterIndex_same, test_columnCount,
              test_getColumnName, test_getColumnIndex_same_case,
              test_getColumnIndex_different_case, test_state_ready,
              test_state_executing, test_state_after_finalize,
              test_getColumnDecltype,
              test_failed_execute,
+             test_bind_undefined,
 ];
 
 function run_test()
 {
   setup();
 
   for (var i = 0; i < tests.length; i++) {
     tests[i]();