Bug 1496588: Avoid a UB in mozStorageService.cpp. r=froydnj, a=IanN CLOSED TREE DONTBUILD SEAMONKEY_2_49_ESR_RELBRANCH
authorDavid Major <dmajor@mozilla.com>
Fri, 05 Oct 2018 16:23:40 -0400
branchSEAMONKEY_2_49_ESR_RELBRANCH
changeset 357552 330002a1e73dc238250a676c071a0a7117996e6b
parent 357551 3887818dfa343134e7846ee75752c85ee38cb1d3
child 357553 6e4ad8a8f2e8092c2406e6864d2beebe9d787dfd
push id7834
push userfrgrahl@gmx.net
push dateSun, 13 Jan 2019 12:17:02 +0000
treeherdermozilla-esr52@6e4ad8a8f2e8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj, IanN
bugs1496588
milestone52.9.1
Bug 1496588: Avoid a UB in mozStorageService.cpp. r=froydnj, a=IanN CLOSED TREE DONTBUILD mozilla-esr52 SEAMONKEY_2_49_ESR_RELBRANCH
storage/mozStorageService.cpp
--- a/storage/mozStorageService.cpp
+++ b/storage/mozStorageService.cpp
@@ -789,18 +789,20 @@ Service::OpenAsyncDatabase(nsIVariant *a
   rv = aDatabaseStore->GetAsISupports(getter_AddRefs(dbStore));
   if (NS_SUCCEEDED(rv)) {
     // Generally, aDatabaseStore holds the database nsIFile.
     storageFile = do_QueryInterface(dbStore, &rv);
     if (NS_FAILED(rv)) {
       return NS_ERROR_INVALID_ARG;
     }
 
-    rv = storageFile->Clone(getter_AddRefs(storageFile));
+    nsCOMPtr<nsIFile> cloned;
+    rv = storageFile->Clone(getter_AddRefs(cloned));
     MOZ_ASSERT(NS_SUCCEEDED(rv));
+    storageFile = cloned.forget();
 
     if (!readOnly) {
       // Ensure that SQLITE_OPEN_CREATE is passed in for compatibility reasons.
       flags |= SQLITE_OPEN_CREATE;
     }
 
     // Apply the shared-cache option.
     flags |= shared ? SQLITE_OPEN_SHAREDCACHE : SQLITE_OPEN_PRIVATECACHE;