Bug 1028588 - Fix dangerous public destructors in storage/ - r=bent
authorBenoit Jacob <bjacob@mozilla.com>
Mon, 23 Jun 2014 18:40:03 -0400
changeset 190362 c928b9f75e7f95c0f60330f7dd0a54a6a0081ad1
parent 190361 fdb81eed139712db471a6327ff3f98bb82d2e57e
child 190363 8f8f2b86ae018ab1a0a70ef31b588e2d8b66cb86
push id27004
push useremorley@mozilla.com
push dateTue, 24 Jun 2014 15:52:34 +0000
treeherdermozilla-central@7b174d47f3cc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbent
bugs1028588
milestone33.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 1028588 - Fix dangerous public destructors in storage/ - r=bent
storage/src/mozStorageArgValueArray.h
storage/src/mozStorageAsyncStatementParams.h
storage/src/mozStorageBindingParams.h
storage/src/mozStorageBindingParamsArray.h
storage/src/mozStorageError.h
storage/src/mozStorageResultSet.h
storage/src/mozStorageRow.h
storage/src/mozStorageStatementParams.h
storage/src/mozStorageStatementRow.h
storage/test/test_async_callbacks_with_spun_event_loops.cpp
--- a/storage/src/mozStorageArgValueArray.h
+++ b/storage/src/mozStorageArgValueArray.h
@@ -19,16 +19,18 @@ class ArgValueArray MOZ_FINAL : public m
 {
 public:
   ArgValueArray(int32_t aArgc, sqlite3_value **aArgv);
 
   NS_DECL_ISUPPORTS
   NS_DECL_MOZISTORAGEVALUEARRAY
 
 private:
+  ~ArgValueArray() {}
+
   uint32_t mArgc;
   sqlite3_value **mArgv;
 };
 
 } // namespace storage
 } // namespace mozilla
 
 #endif // mozStorageArgValueArray_h
--- a/storage/src/mozStorageAsyncStatementParams.h
+++ b/storage/src/mozStorageAsyncStatementParams.h
@@ -29,16 +29,18 @@ public:
   AsyncStatementParams(AsyncStatement *aStatement);
 
   // interfaces
   NS_DECL_ISUPPORTS
   NS_DECL_MOZISTORAGESTATEMENTPARAMS
   NS_DECL_NSIXPCSCRIPTABLE
 
 protected:
+  virtual ~AsyncStatementParams() {}
+
   AsyncStatement *mStatement;
 
   friend class AsyncStatement;
 };
 
 } // namespace storage
 } // namespace mozilla
 
--- a/storage/src/mozStorageBindingParams.h
+++ b/storage/src/mozStorageBindingParams.h
@@ -48,19 +48,19 @@ public:
   /**
    * @returns the pointer to the owning BindingParamsArray.  Used by a
    *          BindingParamsArray to verify that we belong to it when added.
    */
   const mozIStorageBindingParamsArray *getOwner() const;
 
   BindingParams(mozIStorageBindingParamsArray *aOwningArray,
                 Statement *aOwningStatement);
+protected:
   virtual ~BindingParams() {}
 
-protected:
   BindingParams(mozIStorageBindingParamsArray *aOwningArray);
   nsCOMArray<nsIVariant> mParameters;
   bool mLocked;
 
 private:
 
   /**
    * Track the BindingParamsArray that created us until we are added to it.
--- a/storage/src/mozStorageBindingParamsArray.h
+++ b/storage/src/mozStorageBindingParamsArray.h
@@ -17,16 +17,18 @@ namespace mozilla {
 namespace storage {
 
 class StorageBaseStatementInternal;
 
 class BindingParamsArray MOZ_FINAL : public mozIStorageBindingParamsArray
 {
   typedef nsTArray< nsCOMPtr<mozIStorageBindingParams> > array_type;
 
+  ~BindingParamsArray() {}
+
 public:
   NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_MOZISTORAGEBINDINGPARAMSARRAY
 
   BindingParamsArray(StorageBaseStatementInternal *aOwningStatement);
 
   typedef array_type::size_type size_type;
 
--- a/storage/src/mozStorageError.h
+++ b/storage/src/mozStorageError.h
@@ -18,16 +18,18 @@ class Error MOZ_FINAL : public mozIStora
 {
 public:
   NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_MOZISTORAGEERROR
 
   Error(int aResult, const char *aMessage);
 
 private:
+  ~Error() {}
+
   int mResult;
   nsCString mMessage;
 };
 
 } // namespace stoarge
 } // namespace mozilla
 
 #endif // mozStorageError_h
--- a/storage/src/mozStorageResultSet.h
+++ b/storage/src/mozStorageResultSet.h
@@ -17,29 +17,30 @@ namespace storage {
 
 class ResultSet MOZ_FINAL : public mozIStorageResultSet
 {
 public:
   NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_MOZISTORAGERESULTSET
 
   ResultSet();
-  ~ResultSet();
 
   /**
    * Adds a tuple to this result set.
    */
   nsresult add(mozIStorageRow *aTuple);
 
   /**
    * @returns the number of rows this result set holds.
    */
   int32_t rows() const { return mData.Count(); }
 
 private:
+  ~ResultSet();
+
   /**
    * Stores the current index of the active result set.
    */
   int32_t mCurrentIndex;
 
   /**
    * Stores the tuples.
    */
--- a/storage/src/mozStorageRow.h
+++ b/storage/src/mozStorageRow.h
@@ -29,16 +29,18 @@ public:
    * the statement.
    *
    * @param aStatement
    *        The sqlite statement to pull results from.
    */
   nsresult initialize(sqlite3_stmt *aStatement);
 
 private:
+  ~Row() {}
+
   /**
    * The number of columns in this tuple.
    */
   uint32_t mNumCols;
 
   /**
    * Stores the data in the tuple.
    */
--- a/storage/src/mozStorageStatementParams.h
+++ b/storage/src/mozStorageStatementParams.h
@@ -25,16 +25,18 @@ public:
   StatementParams(mozIStorageStatement *aStatement);
 
   // interfaces
   NS_DECL_ISUPPORTS
   NS_DECL_MOZISTORAGESTATEMENTPARAMS
   NS_DECL_NSIXPCSCRIPTABLE
 
 protected:
+  ~StatementParams() {}
+
   mozIStorageStatement *mStatement;
   uint32_t mParamCount;
 
   friend class Statement;
 };
 
 } // namespace storage
 } // namespace mozilla
--- a/storage/src/mozStorageStatementRow.h
+++ b/storage/src/mozStorageStatementRow.h
@@ -22,16 +22,18 @@ class StatementRow MOZ_FINAL : public mo
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_MOZISTORAGESTATEMENTROW
   NS_DECL_NSIXPCSCRIPTABLE
 
   StatementRow(Statement *aStatement);
 protected:
 
+  ~StatementRow() {}
+
   Statement *mStatement;
 
   friend class Statement;
 };
 
 } // namespace storage
 } // namespace mozilla
 
--- a/storage/test/test_async_callbacks_with_spun_event_loops.cpp
+++ b/storage/test/test_async_callbacks_with_spun_event_loops.cpp
@@ -45,22 +45,24 @@ public:
   : mDBConn(aDBConn)
   , mCompleted(false)
   {
     sAlive = true;
     sResult = false;
     sError = false;
   }
 
+private:
   ~UnownedCallback()
   {
     sAlive = false;
     blocking_async_close(mDBConn);
   }
 
+public:
   NS_IMETHOD HandleResult(mozIStorageResultSet* aResultSet)
   {
     sResult = true;
     spin_events_loop_until_true(&mCompleted);
     if (!sAlive) {
       NS_RUNTIMEABORT("The statement callback was destroyed prematurely.");
     }
     return NS_OK;