Bug 1183954, Don't leak nsStructuredCloneContainer (use of 'auto' is error prone), r=leak
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Sun, 02 Aug 2015 12:34:26 +0300
changeset 287442 7921dfab7eb3cb1964d7b113547f37c3b9ebf158
parent 287441 d24ed1ad39df0ae90a4874dec8d70dc183608637
child 287443 523ffd5c4588f1e35a9e22980c20d95b5707b79d
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersleak
bugs1183954
milestone42.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 1183954, Don't leak nsStructuredCloneContainer (use of 'auto' is error prone), r=leak
dom/notification/Notification.cpp
--- a/dom/notification/Notification.cpp
+++ b/dom/notification/Notification.cpp
@@ -1967,17 +1967,18 @@ Notification::GetOrigin(nsIPrincipal* aP
 }
 
 void
 Notification::GetData(JSContext* aCx,
                       JS::MutableHandle<JS::Value> aRetval)
 {
   if (mData.isNull() && !mDataAsBase64.IsEmpty()) {
     nsresult rv;
-    auto container = new nsStructuredCloneContainer();
+    nsRefPtr<nsStructuredCloneContainer> container =
+      new nsStructuredCloneContainer();
     rv = container->InitFromBase64(mDataAsBase64, JS_STRUCTURED_CLONE_VERSION,
                                    aCx);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       aRetval.setNull();
       return;
     }
 
     JS::Rooted<JS::Value> data(aCx);
@@ -2003,34 +2004,36 @@ Notification::GetData(JSContext* aCx,
 
 void
 Notification::InitFromJSVal(JSContext* aCx, JS::Handle<JS::Value> aData,
                             ErrorResult& aRv)
 {
   if (!mDataAsBase64.IsEmpty() || aData.isNull()) {
     return;
   }
-  auto dataObjectContainer = new nsStructuredCloneContainer();
+  nsRefPtr<nsStructuredCloneContainer> dataObjectContainer =
+    new nsStructuredCloneContainer();
   aRv = dataObjectContainer->InitFromJSVal(aData, aCx);
   if (NS_WARN_IF(aRv.Failed())) {
     return;
   }
 
   dataObjectContainer->GetDataAsBase64(mDataAsBase64);
 }
 
 void Notification::InitFromBase64(JSContext* aCx, const nsAString& aData,
                                   ErrorResult& aRv)
 {
   if (!mDataAsBase64.IsEmpty() || aData.IsEmpty()) {
     return;
   }
 
   // To and fro to ensure it is valid base64.
-  auto container = new nsStructuredCloneContainer();
+  nsRefPtr<nsStructuredCloneContainer> container =
+    new nsStructuredCloneContainer();
   aRv = container->InitFromBase64(aData, JS_STRUCTURED_CLONE_VERSION,
                                   aCx);
   if (NS_WARN_IF(aRv.Failed())) {
     return;
   }
 
   container->GetDataAsBase64(mDataAsBase64);
 }