Bug 1200656 - Reading list import from Edge leaks. r=jimm
authorJared Wein <jwein@mozilla.com>
Tue, 08 Sep 2015 08:52:32 -0400
changeset 293931 b14d437728aaf5f232830d8e10de80caa62b22e0
parent 293930 d11e3bc39d961c249ea31c5602ce6dfbfd169245
child 293932 e40065dd77cebf8e6f3ed02a68ad496da313fdf4
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjimm
bugs1200656
milestone43.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 1200656 - Reading list import from Edge leaks. r=jimm
browser/components/migration/nsEdgeReadingListExtractor.cpp
--- a/browser/components/migration/nsEdgeReadingListExtractor.cpp
+++ b/browser/components/migration/nsEdgeReadingListExtractor.cpp
@@ -27,16 +27,20 @@
 NS_IMPL_ISUPPORTS(nsEdgeReadingListExtractor, nsIEdgeReadingListExtractor)
 
 NS_IMETHODIMP
 nsEdgeReadingListExtractor::Extract(const nsAString& aDBPath, nsIArray** aItems)
 {
   nsresult rv = NS_OK;
   *aItems = nullptr;
 
+  if (!aDBPath.Length()) {
+    return NS_ERROR_FAILURE;
+  }
+
   JET_ERR err;
   JET_INSTANCE instance;
   JET_SESID sesid;
   JET_DBID dbid;
   JET_TABLEID tableid;
   JET_COLUMNDEF urlColumnInfo = { 0 };
   JET_COLUMNDEF titleColumnInfo = { 0 };
   JET_COLUMNDEF addedDateColumnInfo = { 0 };
@@ -45,21 +49,19 @@ nsEdgeReadingListExtractor::Extract(cons
   // otherwise the compiler complains.
   nsCOMPtr<nsIMutableArray> items = do_CreateInstance(NS_ARRAY_CONTRACTID);
 
   // JET does not throw exceptions, and so error handling and ensuring we close
   // the DB is a bit finnicky. Keep track of how far we got so we guarantee closing
   // the right things
   bool instanceCreated, sessionCreated, dbOpened, tableOpened;
 
-  char16ptr_t dbPath = ToNewUnicode(aDBPath);
-
   // Check for the right page size and initialize with that
   unsigned long pageSize;
-  err = JetGetDatabaseFileInfoW(dbPath, &pageSize, sizeof(pageSize), JET_DbInfoPageSize);
+  err = JetGetDatabaseFileInfoW(aDBPath.BeginReading(), &pageSize, sizeof(pageSize), JET_DbInfoPageSize);
   NS_HANDLE_JET_ERROR(err)
   err = JetSetSystemParameter(&instance, NULL, JET_paramDatabasePageSize, pageSize, NULL);
   NS_HANDLE_JET_ERROR(err)
 
   // Turn off recovery, because otherwise we will create log files in either the cwd or
   // overwrite Edge's own logfiles, which is useless at best and at worst might mess with
   // Edge actually using the DB
   err = JetSetSystemParameter(&instance, NULL, JET_paramRecovery, NULL, "Off");
@@ -72,20 +74,20 @@ nsEdgeReadingListExtractor::Extract(cons
 
   err = JetInit(&instance);
   NS_HANDLE_JET_ERROR(err)
   err = JetBeginSession(instance, &sesid, 0, 0);
   NS_HANDLE_JET_ERROR(err)
   sessionCreated = true;
 
   // Actually open the DB, and make sure to do so readonly:
-  err = JetAttachDatabaseW(sesid, dbPath, JET_bitDbReadOnly);
+  err = JetAttachDatabaseW(sesid, aDBPath.BeginReading(), JET_bitDbReadOnly);
   NS_HANDLE_JET_ERROR(err)
   dbOpened = true;
-  err = JetOpenDatabaseW(sesid, dbPath, NULL, &dbid, JET_bitDbReadOnly);
+  err = JetOpenDatabaseW(sesid, aDBPath.BeginReading(), NULL, &dbid, JET_bitDbReadOnly);
   NS_HANDLE_JET_ERROR(err)
 
   // Open the readinglist table and get information on the columns we are interested in:
   err = JetOpenTable(sesid, dbid, "ReadingList", NULL, 0, JET_bitTableReadOnly, &tableid);
   NS_HANDLE_JET_ERROR(err)
   tableOpened = true;
   err = JetGetColumnInfo(sesid, dbid, "ReadingList", "URL", &urlColumnInfo,
                          sizeof(urlColumnInfo), JET_ColInfo);