diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2020-12-28 16:03:06 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2020-12-28 21:15:34 +0100 |
commit | f72a5fd03ddfa94b074b28cf1259284f727139f0 (patch) | |
tree | ea378746d2d807d1bc39a7f00ee61e28fe641f63 /include/rtl/stringconcat.hxx | |
parent | c4542dd3534e5e05307938bb7627017fb8a883cb (diff) |
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@redhat.com>
Diffstat (limited to 'include/rtl/stringconcat.hxx')
-rw-r--r-- | include/rtl/stringconcat.hxx | 8 |
1 files changed, 6 insertions, 2 deletions
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; } |