1
0
mirror of synced 2025-01-18 17:14:13 +01:00

fix: Segfault when launching ImHex with file arguments (#1501)

d511080814dc78ad39a63f2071003c07ee37673c introduced a regression where
running imhex with arguments (i.e. `imhex blob1.bin blob2.bin`) will
segfault due to a null pointer dereference.

### Implementation description
This patch updates `getSubCommands` to follow the same control flow as
`getFeatures`, where if the function returns a null pointer, it will
return gracefully rather than crash.
This commit is contained in:
Ada 2024-01-18 10:11:06 +00:00 committed by GitHub
parent ffb324f685
commit cc97c0e525
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -186,6 +186,8 @@ namespace hex {
std::span<SubCommand> Plugin::getSubCommands() const {
if (m_functions.getSubCommandsFunction != nullptr) {
const auto result = m_functions.getSubCommandsFunction();
if (result == nullptr)
return { };
return *static_cast<std::vector<SubCommand>*>(result);
} else {