Bug 1034915 - Don't explicitly call delete on nsExtensibleStringBundle. r=ehsan
authorAndrew McCreight <continuation@gmail.com>
Tue, 08 Jul 2014 13:46:24 -0700
changeset 192869 2e1c25d3cd2ab7580a1c8345abe1cc35215ca3a3
parent 192868 fdbf7d256b43901bfbbeda452b541699350e594c
child 192870 7f6cbfe1a68b95787ceedf1e98b951f8f9a157de
push id45963
push useramccreight@mozilla.com
push dateTue, 08 Jul 2014 20:46:42 +0000
treeherdermozilla-inbound@7f6cbfe1a68b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs1034915
milestone33.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 1034915 - Don't explicitly call delete on nsExtensibleStringBundle. r=ehsan
intl/strres/src/nsStringBundle.cpp
intl/strres/src/nsStringBundle.h
--- a/intl/strres/src/nsStringBundle.cpp
+++ b/intl/strres/src/nsStringBundle.cpp
@@ -632,29 +632,26 @@ nsStringBundleService::CreateBundle(cons
   return getStringBundle(aURLSpec,aResult);
 }
 
 NS_IMETHODIMP
 nsStringBundleService::CreateExtensibleBundle(const char* aCategory,
                                               nsIStringBundle** aResult)
 {
   NS_ENSURE_ARG_POINTER(aResult);
-
-  nsresult res;
+  *aResult = nullptr;
 
-  nsExtensibleStringBundle * bundle = new nsExtensibleStringBundle();
+  nsRefPtr<nsExtensibleStringBundle> bundle = new nsExtensibleStringBundle();
 
-  res = bundle->Init(aCategory, this);
+  nsresult res = bundle->Init(aCategory, this);
   if (NS_FAILED(res)) {
-    delete bundle;
     return res;
   }
 
   res = bundle->QueryInterface(NS_GET_IID(nsIStringBundle), (void**) aResult);
-  if (NS_FAILED(res)) delete bundle;
 
   return res;
 }
 
 #define GLOBAL_PROPERTIES "chrome://global/locale/global-strres.properties"
 
 nsresult
 nsStringBundleService::FormatWithBundle(nsIStringBundle* bundle, nsresult aStatus,
--- a/intl/strres/src/nsStringBundle.h
+++ b/intl/strres/src/nsStringBundle.h
@@ -48,42 +48,34 @@ private:
 public:
     static nsresult FormatString(const char16_t *formatStr,
                                  const char16_t **aParams, uint32_t aLength,
                                  char16_t **aResult);
 };
 
 class nsExtensibleStringBundle;
 
-namespace mozilla {
-template<>
-struct HasDangerousPublicDestructor<nsExtensibleStringBundle>
-{
-  static const bool value = true;
-};
-}
-
 /**
  * An extensible implementation of the StringBundle interface.
  *
  * @created         28/Dec/1999
  * @author  Catalin Rotaru [CATA]
  */
-class nsExtensibleStringBundle : public nsIStringBundle
+class nsExtensibleStringBundle MOZ_FINAL : public nsIStringBundle
 {
   NS_DECL_ISUPPORTS
   NS_DECL_NSISTRINGBUNDLE
 
   nsresult Init(const char * aCategory, nsIStringBundleService *);
+
+public:
+  nsExtensibleStringBundle();
+
 private:
+  virtual ~nsExtensibleStringBundle();
 
   nsCOMArray<nsIStringBundle> mBundles;
-  bool               mLoaded;
-
-public:
-
-  nsExtensibleStringBundle();
-  virtual ~nsExtensibleStringBundle();
+  bool mLoaded;
 };
 
 
 
 #endif