Bug 1437476 - Clone annotation objects before passing to back-end services to avoid leaks. r=mak
authorMark Banner <standard8@mozilla.com>
Wed, 28 Feb 2018 15:59:06 +0000
changeset 405925 06a197051c96
parent 405924 4515d83faaa3
child 405926 b0990ecdb2d6
push id60413
push usermbanner@mozilla.com
push dateThu, 01 Mar 2018 12:40:55 +0000
treeherderautoland@b0990ecdb2d6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs1437476
milestone60.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 1437476 - Clone annotation objects before passing to back-end services to avoid leaks. r=mak MozReview-Commit-ID: 1ke3FK4gQkL
toolkit/components/places/PlacesTransactions.jsm
--- a/toolkit/components/places/PlacesTransactions.jsm
+++ b/toolkit/components/places/PlacesTransactions.jsm
@@ -732,18 +732,21 @@ function checkProperty(obj, prop, requir
 DefineTransaction.annotationObjectValidate = function(obj) {
   if (obj &&
       checkProperty(obj, "name", true, v => typeof(v) == "string" && v.length > 0) &&
       checkProperty(obj, "expires", false, Number.isInteger) &&
       checkProperty(obj, "flags", false, Number.isInteger) &&
       checkProperty(obj, "value", false, isPrimitive) ) {
     // Nothing else should be set
     let validKeys = ["name", "value", "flags", "expires"];
-    if (Object.keys(obj).every(k => validKeys.includes(k)))
-      return obj;
+    if (Object.keys(obj).every(k => validKeys.includes(k))) {
+      // Annotations objects are passed through to the backend, to avoid memory
+      // leaks, we must clone the object.
+      return {...obj};
+    }
   }
   throw new Error("Invalid annotation object");
 };
 
 DefineTransaction.childObjectValidate = function(obj) {
   if (obj &&
       checkProperty(obj, "title", false, v => typeof(v) == "string") &&
       !("type" in obj && obj.type != PlacesUtils.bookmarks.TYPE_BOOKMARK)) {