Skip to content

Commit

Permalink
Fix UB in MinidumpWriter::WriteExceptionStream() calling memcpy()
Browse files Browse the repository at this point in the history
It passed null pointer as a second argument to std::memcpy() when
crash_exception_info was empty. This exhibited the undefined behavior.
  • Loading branch information
sergio-nsk committed Aug 7, 2024
1 parent 5662ef0 commit 8646f2b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/client/linux/minidump_writer/minidump_writer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -772,9 +772,11 @@ class MinidumpWriter {
const std::vector<uint64_t> crash_exception_info =
dumper_->crash_exception_info();
stream->exception_record.number_parameters = crash_exception_info.size();
memcpy(stream->exception_record.exception_information,
crash_exception_info.data(),
sizeof(uint64_t) * crash_exception_info.size());
if (!crash_exception_info.empty()) {
memcpy(stream->exception_record.exception_information,
crash_exception_info.data(),
sizeof(uint64_t) * crash_exception_info.size());
}
stream->thread_context = crashing_thread_context_;

return true;
Expand Down

0 comments on commit 8646f2b

Please sign in to comment.