[Libreoffice-commits] core.git: registry/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Jul 26 14:26:45 UTC 2018


 registry/source/reflwrit.cxx |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

New commits:
commit d9f81ecb1f8a6142379d85a7c6b1fdb54c57ad22
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Thu Jul 26 10:48:53 2018 +0100
Commit:     Stephan Bergmann <sbergman at redhat.com>
CommitDate: Thu Jul 26 16:26:18 2018 +0200

    Related: rhbz#1602589 silence error[memleak]: Memory leak: newValue
    
    Change-Id: I2d04c75aa9b5e1d91e06992fdb99899657ecf96d
    Reviewed-on: https://gerrit.libreoffice.org/58062
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>

diff --git a/registry/source/reflwrit.cxx b/registry/source/reflwrit.cxx
index 53b6d9d0e175..dc3e2a15b603 100644
--- a/registry/source/reflwrit.cxx
+++ b/registry/source/reflwrit.cxx
@@ -377,11 +377,11 @@ void FieldEntry::setData(const OString&    name,
                          RTValueType        constValueType,
                          RTConstValueUnion  constValue)
 {
-    sal_Unicode * newValue = nullptr;
+    std::unique_ptr<sal_Unicode[]> newValue;
     if (constValueType == RT_TYPE_STRING && constValue.aString != nullptr) {
         sal_Int32 n = rtl_ustr_getLength(constValue.aString) + 1;
-        newValue = new sal_Unicode[n];
-        memcpy(newValue, constValue.aString, n * sizeof (sal_Unicode));
+        newValue.reset(new sal_Unicode[n]);
+        memcpy(newValue.get(), constValue.aString, n * sizeof (sal_Unicode));
     }
 
     m_name = name;
@@ -407,7 +407,7 @@ void FieldEntry::setData(const OString&    name,
             m_constValue.aString = NULL_WSTRING;
         else
         {
-            m_constValue.aString = newValue;
+            m_constValue.aString = newValue.release();
         }
     }
     else


More information about the Libreoffice-commits mailing list