diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2019-07-29 09:04:52 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2019-07-29 10:21:45 +0200 |
commit | b8106018ab997931c872219986e2e9aa88b774af (patch) | |
tree | 24fc9524dd22d31cb8f885f9220a129704e29ba2 /jvmfwk | |
parent | 1c43baff792663494a79e923bea81e702baefc5d (diff) |
Avoid memcpy nonnull issue
...as started to get reported by <https://ci.libreoffice.org/job/lo_ubsan/1341/>
> /jvmfwk/plugins/sunmajor/pluginlib/util.cxx:368:33: runtime error: null pointer passed as argument 2, which is declared to never be null
/usr/include/string.h:43:28: note: nonnull attribute specified here
> #0 0x2b710cdb4e35 in jfw_plugin::AsynchReader::execute() /jvmfwk/plugins/sunmajor/pluginlib/util.cxx:368:13
> #1 0x2b70c87b8a27 in salhelper::Thread::run() /salhelper/source/thread.cxx:40:9
> #2 0x2b70c87bac9f in threadFunc /include/osl/thread.hxx:185:15
> #3 0x2b70ba8bb89d in osl_thread_start_Impl(void*) /sal/osl/unx/thread.cxx:235:9
> #4 0x2b70bc47fdd4 in start_thread (/lib64/libpthread.so.0+0x7dd4)
> #5 0x2b70bcdb4eac in clone (/lib64/libc.so.6+0xfdeac)
during UITest_calc_tests6
Change-Id: I6505061192a8d6b9a68d72980fd134d161e5e1a3
Reviewed-on: https://gerrit.libreoffice.org/76516
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'jvmfwk')
-rw-r--r-- | jvmfwk/plugins/sunmajor/pluginlib/util.cxx | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/jvmfwk/plugins/sunmajor/pluginlib/util.cxx b/jvmfwk/plugins/sunmajor/pluginlib/util.cxx index d8238120b04c..f703fb4c200b 100644 --- a/jvmfwk/plugins/sunmajor/pluginlib/util.cxx +++ b/jvmfwk/plugins/sunmajor/pluginlib/util.cxx @@ -365,7 +365,9 @@ void AsynchReader::execute() { //Save the data we have in m_arData into a temporary array std::unique_ptr<sal_Char[]> arTmp( new sal_Char[m_nDataSize]); - memcpy(arTmp.get(), m_arData.get(), m_nDataSize); + if (m_nDataSize != 0) { + memcpy(arTmp.get(), m_arData.get(), m_nDataSize); + } //Enlarge m_arData to hold the newly read data m_arData.reset(new sal_Char[static_cast<size_t>(m_nDataSize + nRead)]); //Copy back the data that was already in m_arData |