From 821b75299381e498d3d75f665a722d58af26bf9c Mon Sep 17 00:00:00 2001 From: Ralf Donau Date: Sat, 10 Jul 2021 10:27:43 +0200 Subject: [PATCH] Userland: Add fopen error handling to less --- Userland/Utilities/less.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Userland/Utilities/less.cpp b/Userland/Utilities/less.cpp index 5174c64bfc..34728104e4 100644 --- a/Userland/Utilities/less.cpp +++ b/Userland/Utilities/less.cpp @@ -331,8 +331,9 @@ int main(int argc, char** argv) FILE* file; if (String("-") == filename) { file = stdin; - } else { - file = fopen(filename, "r"); + } else if ((file = fopen(filename, "r")) == nullptr) { + perror("fopen"); + exit(1); } if (pledge("stdio tty", nullptr) < 0) {