From d429bcfe822ea920ebeebbca7ab57b6873822f51 Mon Sep 17 00:00:00 2001 From: Steffen Winter Date: Sun, 1 Jun 2025 23:42:47 +0200 Subject: [PATCH] Exit gracefully if integer conversion in CLI parser fails --- src/btop_cli.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/btop_cli.cpp b/src/btop_cli.cpp index bf1b4d97..f867ca6e 100644 --- a/src/btop_cli.cpp +++ b/src/btop_cli.cpp @@ -124,6 +124,9 @@ namespace Cli { } catch (std::invalid_argument& e) { error("Preset must be a positive number"); return OrRetCode { 1 }; + } catch (std::out_of_range& e) { + error(fmt::format("Preset argument is out of range: {}", arg.data())); + return OrRetCode { 1 }; } continue; } @@ -141,6 +144,9 @@ namespace Cli { } catch (std::invalid_argument& e) { error("Update must be a positive number"); return OrRetCode { 1 }; + } catch(std::out_of_range& e) { + error(fmt::format("Update argument is out of range: {}", arg.data())); + return OrRetCode { 1 }; } continue; }