From 59af451a99046bb8deb9ad5a151e3b0cab8168ac Mon Sep 17 00:00:00 2001 From: Yuri Kanivetsky Date: Tue, 28 May 2024 07:41:16 +0300 Subject: [PATCH] Fix handling small files with small files std::cin.fail() and it crashes --- commands.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/commands.cpp b/commands.cpp index 6b3c498..85e2f21 100644 --- a/commands.cpp +++ b/commands.cpp @@ -896,7 +896,8 @@ int smudge (int argc, const char** argv) std::clog << "git-crypt: file contains sensitive information, you can use 'git filter-branch'" << std::endl; std::clog << "git-crypt: to remove its old versions from the history." << std::endl; std::cout.write(reinterpret_cast(header), std::cin.gcount()); // include the bytes which we already read - std::cout << std::cin.rdbuf(); + if (!std::cin.fail()) + std::cout << std::cin.rdbuf(); return 0; }