From efd5165707d37479c42cb7e2e87130c0662f32e3 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 17 Jan 2025 23:27:36 -0500 Subject: [PATCH] avoid segfaults if there was no input processing --- src/utils.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/utils.cpp b/src/utils.cpp index 71a662a7e9..0007b11e9c 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -183,7 +183,7 @@ void utils::missing_cmd_args(const std::string &file, int line, const std::strin std::string utils::point_to_error(Input *input, int failed) { - if (input) { + if (input && input->line && input->command) { std::string lastline = utils::strcompress(input->line); std::string lastargs = input->command; std::string cmdline = "Last input line: "; @@ -237,12 +237,12 @@ std::string utils::point_to_error(Input *input, int failed) cmdline += '\n'; } else { - cmdline += input->line; + cmdline += lastline; cmdline += '\n'; } return cmdline; } else - return std::string("(Failed input line text not available)"); + return std::string(""); } /* specialization for the case of just a single string argument */