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

New commits:
commit f72a5fd03ddfa94b074b28cf1259284f727139f0
Author:     Stephan Bergmann <[email protected]>
AuthorDate: Mon Dec 28 16:03:06 2020 +0100
Commit:     Stephan Bergmann <[email protected]>
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 <[email protected]>

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;
     }
 
_______________________________________________
Libreoffice-commits mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to