[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-1+backports' - dtrans/source onlineupdate/source vcl/opengl vcl/win

Jan-Marek Glogowski (via logerrit) logerrit at kemper.freedesktop.org
Tue Jun 4 07:02:30 UTC 2019


 dtrans/source/win32/misc/ImplHelper.cxx        |    2 -
 onlineupdate/source/update/updater/updater.cxx |   32 ++++++++++++-------------
 vcl/opengl/win/WinDeviceInfo.cxx               |    2 -
 vcl/win/app/salinst.cxx                        |    2 -
 vcl/win/window/salframe.cxx                    |    4 +--
 5 files changed, 21 insertions(+), 21 deletions(-)

New commits:
commit 6a48679fc4a38f34f8bf0c1ff0a4ef7bad384b9c
Author:     Jan-Marek Glogowski <glogow at fbihome.de>
AuthorDate: Fri Sep 7 16:09:50 2018 +0200
Commit:     Juergen Funk (CIB) <juergen.funk_ml at cib.de>
CommitDate: Tue Jun 4 09:01:56 2019 +0200

    Fix some std::unique_ptr array allocs
    
    Found by reviewing the output of and the code around
    git grep -n "unique_ptr.*new.*\[.*\]" | grep -v "\[\]"
    
    The onlineupdater code needs a little bit more attention.
    
    Change-Id: I8b70c7da7db60af52bfac12314a21602ede8bfc0
    Reviewed-on: https://gerrit.libreoffice.org/60162
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
    (cherry picked from commit b18747fcee1ba8744e5cd63791dc9f3eb6848a56)
    Reviewed-on: https://gerrit.libreoffice.org/73428
    Reviewed-by: Juergen Funk (CIB) <juergen.funk_ml at cib.de>
    Tested-by: Juergen Funk (CIB) <juergen.funk_ml at cib.de>

diff --git a/dtrans/source/win32/misc/ImplHelper.cxx b/dtrans/source/win32/misc/ImplHelper.cxx
index 4b98b4850006..f933701ce961 100644
--- a/dtrans/source/win32/misc/ImplHelper.cxx
+++ b/dtrans/source/win32/misc/ImplHelper.cxx
@@ -95,7 +95,7 @@ OUString getWinCPFromLocaleId( LCID lcid, LCTYPE lctype )
 
     if ( nResult )
     {
-        std::unique_ptr<wchar_t> buff( new wchar_t[nResult] );
+        std::unique_ptr<wchar_t[]> buff( new wchar_t[nResult] );
         // Now get the actual data
         nResult = GetLocaleInfoW( lcid, lctype, buff.get(), nResult );
 
diff --git a/onlineupdate/source/update/updater/updater.cxx b/onlineupdate/source/update/updater/updater.cxx
index 1782804eff15..a05fd075bd3a 100644
--- a/onlineupdate/source/update/updater/updater.cxx
+++ b/onlineupdate/source/update/updater/updater.cxx
@@ -1119,8 +1119,8 @@ public:
     void Finish(int status);
 
 private:
-    std::unique_ptr<const NS_tchar> mFile;
-    std::unique_ptr<NS_tchar> mRelPath;
+    std::unique_ptr<const NS_tchar[]> mFile;
+    std::unique_ptr<NS_tchar[]> mRelPath;
     int mSkip;
 };
 
@@ -1247,8 +1247,8 @@ public:
     virtual void Finish(int status);
 
 private:
-    std::unique_ptr<NS_tchar> mDir;
-    std::unique_ptr<NS_tchar> mRelPath;
+    std::unique_ptr<NS_tchar[]> mDir;
+    std::unique_ptr<NS_tchar[]> mRelPath;
     int mSkip;
 };
 
@@ -1260,6 +1260,7 @@ RemoveDir::Parse(NS_tchar *line)
     NS_tchar* validPath = get_valid_path(&line, true);
     if (!validPath)
         return PARSE_ERROR;
+
     mRelPath.reset(new NS_tchar[MAXPATHLEN]);
     NS_tstrcpy(mRelPath.get(), validPath);
 
@@ -1371,8 +1372,8 @@ public:
     virtual void Finish(int status);
 
 private:
-    std::unique_ptr<NS_tchar> mFile;
-    std::unique_ptr<NS_tchar> mRelPath;
+    std::unique_ptr<NS_tchar[]> mFile;
+    std::unique_ptr<NS_tchar[]> mRelPath;
     bool mAdded;
     ArchiveReader& mArchiveReader;
 };
@@ -1387,7 +1388,6 @@ AddFile::Parse(NS_tchar *line)
         return PARSE_ERROR;
 
     mRelPath.reset(new NS_tchar[MAXPATHLEN]);
-
     NS_tstrcpy(mRelPath.get(), validPath);
 
     mFile.reset(get_full_path(validPath));
@@ -1799,7 +1799,7 @@ public:
     virtual void Finish(int status);
 
 protected:
-    std::unique_ptr<NS_tchar> mTestFile;
+    std::unique_ptr<NS_tchar[]> mTestFile;
 };
 
 AddIfFile::AddIfFile(ArchiveReader& archiveReader):
@@ -1866,7 +1866,7 @@ public:
     virtual void Finish(int status);
 
 protected:
-    std::unique_ptr<NS_tchar> mTestFile;
+    std::unique_ptr<NS_tchar[]> mTestFile;
 };
 
 AddIfNotFile::AddIfNotFile(ArchiveReader& archiveReader):
@@ -1933,7 +1933,7 @@ public:
     virtual void Finish(int status);
 
 private:
-    std::unique_ptr<NS_tchar> mTestFile;
+    std::unique_ptr<NS_tchar[]> mTestFile;
 };
 
 PatchIfFile::PatchIfFile(ArchiveReader& archiveReader):
@@ -2323,7 +2323,7 @@ CopyInstallDirToDestDir()
 #endif
     copy_recursive_skiplist<SKIPLIST_COUNT> skiplist;
 
-    std::unique_ptr<NS_tchar> pUserProfile(new NS_tchar[MAXPATHLEN]);
+    std::unique_ptr<NS_tchar[]> pUserProfile(new NS_tchar[MAXPATHLEN]);
     NS_tstrcpy(pUserProfile.get(), gPatchDirPath);
     NS_tchar *slash = (NS_tchar *) NS_tstrrchr(pUserProfile.get(), NS_T('/'));
     if (slash)
@@ -4036,7 +4036,7 @@ int add_dir_entries(const NS_tchar *dirpath, ActionList *list)
 
     NS_tsnprintf(searchspec, sizeof(searchspec)/sizeof(searchspec[0]),
                  NS_T("%s*"), dirpath);
-    std::unique_ptr<const NS_tchar> pszSpec(get_full_path(searchspec));
+    std::unique_ptr<const NS_tchar[]> pszSpec(get_full_path(searchspec));
 
     hFindFile = FindFirstFileW(pszSpec.get(), &finddata);
     if (hFindFile != INVALID_HANDLE_VALUE)
@@ -4116,7 +4116,7 @@ int add_dir_entries(const NS_tchar *dirpath, ActionList *list)
         char chars[MAXNAMLEN];
     } ent_buf;
     struct dirent* ent;
-    std::unique_ptr<NS_tchar> searchpath(get_full_path(dirpath));
+    std::unique_ptr<NS_tchar[]> searchpath(get_full_path(dirpath));
 
     DIR* dir = opendir(searchpath.get());
     if (!dir)
@@ -4206,7 +4206,7 @@ int add_dir_entries(const NS_tchar *dirpath, ActionList *list)
     int rv = OK;
     FTS *ftsdir;
     FTSENT *ftsdirEntry;
-    std::unique_ptr<NS_tchar> searchpath(get_full_path(dirpath));
+    std::unique_ptr<NS_tchar[]> searchpath(get_full_path(dirpath));
 
     // Remove the trailing slash so the paths don't contain double slashes. The
     // existence of the slash has already been checked in DoUpdate.
@@ -4384,10 +4384,10 @@ GetManifestContents(const NS_tchar *manifest)
 int AddPreCompleteActions(ActionList *list)
 {
 #ifdef MACOSX
-    std::unique_ptr<NS_tchar> manifestPath(get_full_path(
+    std::unique_ptr<NS_tchar[]> manifestPath(get_full_path(
             NS_T("Contents/Resources/precomplete")));
 #else
-    std::unique_ptr<NS_tchar> manifestPath(get_full_path(
+    std::unique_ptr<NS_tchar[]> manifestPath(get_full_path(
             NS_T("precomplete")));
 #endif
 
diff --git a/vcl/opengl/win/WinDeviceInfo.cxx b/vcl/opengl/win/WinDeviceInfo.cxx
index 9b4438cbccdb..ccf87cacb9e8 100644
--- a/vcl/opengl/win/WinDeviceInfo.cxx
+++ b/vcl/opengl/win/WinDeviceInfo.cxx
@@ -210,7 +210,7 @@ int32_t WindowsOSVersion()
                 dwCount = GetFileVersionInfoSizeW(szPath, nullptr);
                 if (dwCount != 0)
                 {
-                    std::unique_ptr<char> ver(new char[dwCount]);
+                    std::unique_ptr<char[]> ver(new char[dwCount]);
                     if (GetFileVersionInfoW(szPath, 0, dwCount, ver.get()) != FALSE)
                     {
                         void* pBlock = nullptr;
diff --git a/vcl/win/app/salinst.cxx b/vcl/win/app/salinst.cxx
index e5868adcea8c..6f504df887c1 100644
--- a/vcl/win/app/salinst.cxx
+++ b/vcl/win/app/salinst.cxx
@@ -1061,7 +1061,7 @@ OUString WinSalInstance::getOSVersion()
             dwCount = GetFileVersionInfoSizeW(szPath, nullptr);
             if (dwCount != 0)
             {
-                std::unique_ptr<char> ver(new char[dwCount]);
+                std::unique_ptr<char[]> ver(new char[dwCount]);
                 if (GetFileVersionInfoW(szPath, 0, dwCount, ver.get()) != FALSE)
                 {
                     void* pBlock = nullptr;
diff --git a/vcl/win/window/salframe.cxx b/vcl/win/window/salframe.cxx
index 5f1b926c9229..95aa32dc4f08 100644
--- a/vcl/win/window/salframe.cxx
+++ b/vcl/win/window/salframe.cxx
@@ -4986,12 +4986,12 @@ static bool ImplHandleIMECompositionInput( WinSalFrame* pFrame,
         if ( nTextLen > 0 )
         {
             {
-                auto pTextBuf = std::unique_ptr<WCHAR>(new WCHAR[nTextLen]);
+                auto pTextBuf = std::unique_ptr<WCHAR[]>(new WCHAR[nTextLen]);
                 ImmGetCompositionStringW( hIMC, GCS_COMPSTR, pTextBuf.get(), nTextLen*sizeof( WCHAR ) );
                 aEvt.maText = OUString( o3tl::toU(pTextBuf.get()), static_cast<sal_Int32>(nTextLen) );
             }
 
-            std::unique_ptr<BYTE> pAttrBuf;
+            std::unique_ptr<BYTE[]> pAttrBuf;
             LONG        nAttrLen = ImmGetCompositionStringW( hIMC, GCS_COMPATTR, nullptr, 0 );
             if ( nAttrLen > 0 )
             {


More information about the Libreoffice-commits mailing list