From 52ae70f6509a28c389a9685b0f173f64293b231a Mon Sep 17 00:00:00 2001 From: FlightlessMango Date: Mon, 13 Dec 2021 14:33:39 +0100 Subject: [PATCH] read_line: return empty line if ifstream fails --- src/file_utils.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/file_utils.cpp b/src/file_utils.cpp index cb8a521..29b1e0b 100644 --- a/src/file_utils.cpp +++ b/src/file_utils.cpp @@ -14,6 +14,9 @@ std::string read_line(const std::string& filename) { std::string line; std::ifstream file(filename); + if (file.fail()){ + return line; + } std::getline(file, line); return line; }