basctl/source/dlged/dlged.cxx  |   11 ++++++-----
 basic/source/classes/image.cxx |    3 ++-
 2 files changed, 8 insertions(+), 6 deletions(-)

New commits:
commit 90490e7436ab8d823994b50472622d1c83fa118e
Author:     Akshay Kumar Dubey <akshaymani...@gmail.com>
AuthorDate: Mon Mar 17 21:57:16 2025 +0530
Commit:     Ilmari Lauhakangas <ilmari.lauhakan...@libreoffice.org>
CommitDate: Tue Mar 18 14:26:14 2025 +0100

    tdf#163691 Use std::copy() instead of memcpy().
    
    Change-Id: I4fbbb4f53542c2b5b86722f7721c51fb8dacd83b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183038
    Tested-by: Jenkins
    Reviewed-by: Ilmari Lauhakangas <ilmari.lauhakan...@libreoffice.org>
    Tested-by: Ilmari Lauhakangas <ilmari.lauhakan...@libreoffice.org>

diff --git a/basctl/source/dlged/dlged.cxx b/basctl/source/dlged/dlged.cxx
index a2a58116b1c8..8550bf6805f4 100644
--- a/basctl/source/dlged/dlged.cxx
+++ b/basctl/source/dlged/dlged.cxx
@@ -48,6 +48,7 @@
 #include <xmlscript/xml_helper.hxx>
 #include <xmlscript/xmldlg_imexp.hxx>
 #include <osl/diagnose.h>
+#include <algorithm>
 
 namespace basctl
 {
@@ -637,7 +638,7 @@ static void implCopyStreamToByteSequence( const Reference< 
XInputStream >& xStre
 
         sal_Int32 nPos = bytes.getLength();
         bytes.realloc( nPos + nRead );
-        memcpy( bytes.getArray() + nPos, readBytes.getConstArray(), 
static_cast<sal_uInt32>(nRead) );
+        std::copy(readBytes.getConstArray(), readBytes.getConstArray() + 
static_cast<sal_uInt32>(nRead), bytes.getArray() + nPos);
     }
 }
 
@@ -761,8 +762,8 @@ void DlgEditor::Copy()
             pCombinedData[i] = sal_Int8( n & 0xff );
             n >>= 8;
         }
-        memcpy( pCombinedData + 4, DialogModelBytes.getConstArray(), 
nDialogDataLen );
-        memcpy( pCombinedData + nResOffset, aResData.getConstArray(), 
nResDataLen );
+        std::copy(DialogModelBytes.getConstArray(), 
DialogModelBytes.getConstArray() + nDialogDataLen, pCombinedData + 4);
+        std::copy(aResData.getConstArray(), aResData.getConstArray() + 
nResDataLen, pCombinedData + nResOffset);
 
         Sequence< Any > aSeqData
         {
@@ -859,10 +860,10 @@ void DlgEditor::Paste()
             sal_Int32 nDialogDataLen = nTotalLen - nResDataLen - 4;
 
             DialogModelBytes.realloc(nDialogDataLen);
-            memcpy(DialogModelBytes.getArray(), aCombinedData.getConstArray() 
+ 4, nDialogDataLen);
+            std::copy(aCombinedData.getConstArray() + 4, 
aCombinedData.getConstArray() + 4 + nDialogDataLen, 
DialogModelBytes.getArray());
 
             aResData.realloc(nResDataLen);
-            memcpy(aResData.getArray(), aCombinedData.getConstArray() + 
nResOffset, nResDataLen);
+            std::copy(aCombinedData.getConstArray() + nResOffset, 
aCombinedData.getConstArray() + nResOffset + nResDataLen, aResData.getArray());
         }
     }
     else
diff --git a/basic/source/classes/image.cxx b/basic/source/classes/image.cxx
index 336666300fd2..95e9a26ae6b2 100644
--- a/basic/source/classes/image.cxx
+++ b/basic/source/classes/image.cxx
@@ -30,6 +30,7 @@
 #include <codegen.hxx>
 #include <memory>
 #include <string_view>
+#include <algorithm>
 
 SbiImage::SbiImage()
     : bError(false)
@@ -576,7 +577,7 @@ void SbiImage::AddString( const OUString& r )
     if( !bError )
     {
         mvStringOffsets[ nStringIdx++ ] = nStringOff;
-        memcpy( pStrings.get() + nStringOff, r.getStr(), len * sizeof( 
sal_Unicode ) );
+        std::copy(r.getStr(), r.getStr() + len, pStrings.get() + nStringOff);
         nStringOff = nStringOff + len;
         // Last String? The update the size of the buffer
         if( nStringIdx >= mvStringOffsets.size() )

Reply via email to