From 28226b85d447087c71b59d3c0f1f5f3ab8cfa8f5 Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Wed, 1 Nov 2023 17:29:26 +1300 Subject: [PATCH] Avoid intermediate buffer Resolves #3638 --- src/AddressSpace.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/AddressSpace.cc b/src/AddressSpace.cc index 6566a5399f8..18a29a37d97 100644 --- a/src/AddressSpace.cc +++ b/src/AddressSpace.cc @@ -374,14 +374,14 @@ vector AddressSpace::read_rr_page_for_recording(SupportedArch arch) { } ScopedFd page(path.c_str(), O_RDONLY); - char buf[PRELOAD_LIBRARY_PAGE_SIZE]; + vector result; + result.resize(PRELOAD_LIBRARY_PAGE_SIZE); ssize_t ret = read_to_end(page, - RRPAGE_RECORD_PAGE_OFFSET * PRELOAD_LIBRARY_PAGE_SIZE, buf, sizeof(buf)); - if (ret != PRELOAD_LIBRARY_PAGE_SIZE) { + RRPAGE_RECORD_PAGE_OFFSET * PRELOAD_LIBRARY_PAGE_SIZE, result.data(), + result.size()); + if (ret != static_cast(result.size())) { FATAL() << "Failed to read full page from " << path; } - vector result; - result.insert(result.end(), buf, buf + sizeof(buf)); return result; }