From 87d9148b822bbae6286289199d535c79f2df64cf Mon Sep 17 00:00:00 2001 From: Syed Daanish Date: Sun, 30 Aug 2026 13:08:48 +0100 Subject: [PATCH] Fix segv on uninitialized command fields. --- include/internal/parser/parser.h | 6 +++--- src/bed/run.cc | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/include/internal/parser/parser.h b/include/internal/parser/parser.h index 033187f..aee2cb3 100644 --- a/include/internal/parser/parser.h +++ b/include/internal/parser/parser.h @@ -65,10 +65,10 @@ struct AddressPromise { struct Command { bool temp_address{false}; std::vector addresses{}; - functions::Function *function; - functions::Function::Argument argument; + functions::Function *function{nullptr}; + functions::Function::Argument argument{std::monostate()}; std::vector argument_addresses{}; - functions::Suffix *suffix; + functions::Suffix *suffix{nullptr}; }; struct CompletionContext { diff --git a/src/bed/run.cc b/src/bed/run.cc index 6104575..c6cdcf2 100644 --- a/src/bed/run.cc +++ b/src/bed/run.cc @@ -124,7 +124,8 @@ void BEd::handle(std::string_view cmd, bool eof) { throw ed_error("Line number can't be zero."); } } - c.function->handle(*this, address, nullptr, c.argument, nullptr); + if (c.function->handle) + c.function->handle(*this, address, nullptr, c.argument, nullptr); if (c.suffix) c.suffix->handle(*this); if (c.temp_address)