From f109f0067a651eeb85d2236349b1317de0019df5 Mon Sep 17 00:00:00 2001 From: chaoticgd <43898262+chaoticgd@users.noreply.github.com> Date: Tue, 22 Oct 2024 03:34:18 +0100 Subject: [PATCH] Fix crash in stdump command line argument parser --- CHANGELOG.md | 1 + src/stdump.cpp | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 65a0679..855c954 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - Mac builds compiled for x64 processors are now provided in addition to the arm64 builds. - stdump: The `functions` and `globals` subcommands now output a header comment like the `types` command. - stdump: The output format of the `files` subcommand has been updated. +- stdump: A crash in the command line parser has been fixed. ## v2.1 diff --git a/src/stdump.cpp b/src/stdump.cpp index 94c5ec6..edb7f6c 100644 --- a/src/stdump.cpp +++ b/src/stdump.cpp @@ -565,7 +565,11 @@ static Options parse_command_line_arguments(int argc, char** argv) if(i + 2 < argc) { SymbolTableLocation& section = options.sections.emplace_back(); section.section_name = argv[++i]; - section.format = symbol_table_format_from_name(argv[++i])->format; + + const SymbolTableFormatInfo* info = symbol_table_format_from_name(argv[++i]); + CCC_EXIT_IF_FALSE(info, "Invalid symbol table format specified."); + + section.format = info->format; } else if(i + 1 < argc) { CCC_EXIT("Missing format after --section."); } else {