[Libreoffice-commits] core.git: include/rtl

Stephan Bergmann (via logerrit) logerrit at kemper.freedesktop.org
Mon Dec 28 20:16:13 UTC 2020


 include/rtl/stringconcat.hxx |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

New commits:
commit f72a5fd03ddfa94b074b28cf1259284f727139f0
Author:     Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Mon Dec 28 16:03:06 2020 +0100
Commit:     Stephan Bergmann <sbergman at redhat.com>
CommitDate: Mon Dec 28 21:15:34 2020 +0100

    Avoid calling memcpy with nullptr
    
    ...which can easily happen when default-constructed std::[u16]string_view are
    involved
    
    Change-Id: I2b11b3943ccaa5344cf9d1f4546d756bc4a2d10f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108414
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>

diff --git a/include/rtl/stringconcat.hxx b/include/rtl/stringconcat.hxx
index e2cba5d86f0d..7f55d6c3473d 100644
--- a/include/rtl/stringconcat.hxx
+++ b/include/rtl/stringconcat.hxx
@@ -74,14 +74,18 @@ struct ToStringHelper
 inline
 char* addDataHelper( char* buffer, const char* data, std::size_t length )
     {
-    memcpy( buffer, data, length );
+    if (length != 0) {
+        memcpy( buffer, data, length );
+    }
     return buffer + length;
     }
 
 inline
 sal_Unicode* addDataHelper( sal_Unicode* buffer, const sal_Unicode* data, std::size_t length )
     {
-    memcpy( buffer, data, length * sizeof( sal_Unicode ));
+    if (length != 0) {
+        memcpy( buffer, data, length * sizeof( sal_Unicode ));
+    }
     return buffer + length;
     }
 


More information about the Libreoffice-commits mailing list