From 67f01fd82eb74bc4eabb1273a300d17784167283 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Boric Date: Thu, 18 Mar 2021 22:58:39 +0100 Subject: [PATCH] checksum: Don't read the entire input file in memory Unsurprisingly, this doesn't work too well if the input file is in the gigabyte range. --- Userland/Utilities/checksum.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Userland/Utilities/checksum.cpp b/Userland/Utilities/checksum.cpp index 21c0eb43ee..156f2dc0dd 100644 --- a/Userland/Utilities/checksum.cpp +++ b/Userland/Utilities/checksum.cpp @@ -85,7 +85,9 @@ int main(int argc, char** argv) has_error = true; continue; } - hash.update(file->read_all()); + + while (!file->eof() && !file->has_error()) + hash.update(file->read(PAGE_SIZE)); auto digest = hash.digest(); auto digest_data = digest.immutable_data(); StringBuilder builder;