Bug 1437476 - Clone annotation objects before passing to back-end services to avoid leaks. r=mak

MozReview-Commit-ID: 1ke3FK4gQkL

--HG--
extra : rebase_source : 6f89b803f8c5ea42bf9ec4c65538d9b293aa2d4e
This commit is contained in:
Mark Banner 2018-02-28 15:59:06 +00:00
parent e3ba763e10
commit 199e734a04

View File

@ -737,8 +737,11 @@ DefineTransaction.annotationObjectValidate = function(obj) {
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");
};