From 6fb533c458fadf896b590724cb6f8f4e2345af76 Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Fri, 8 Mar 2024 08:58:21 +1300 Subject: [PATCH] Avoid passing an null pointer to `memcpy` --- src/TraceStream.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/TraceStream.cc b/src/TraceStream.cc index 9beb06746c9..178ed91bcf6 100644 --- a/src/TraceStream.cc +++ b/src/TraceStream.cc @@ -669,8 +669,10 @@ TraceFrame TraceReader::read_frame(FrameTime skip_before) { auto mprotect_records = event.getSyscallbufFlush().getMprotectRecords(); auto& records = ret.ev.SyscallbufFlush().mprotect_records; records.resize(mprotect_records.size() / sizeof(mprotect_record)); - memcpy(records.data(), mprotect_records.begin(), - records.size() * sizeof(mprotect_record)); + if (records.data()) { + memcpy(records.data(), mprotect_records.begin(), + records.size() * sizeof(mprotect_record)); + } break; } case trace::Frame::Event::SYSCALL: {