Skip to content

Fix CmdParser::removeCmd erasing the wrong command on duplicate IDs - #801

Open
MarkRose wants to merge 1 commit into
sm0svx:masterfrom
MarkRose:fix-cmdparser-removecmd-by-pointer
Open

Fix CmdParser::removeCmd erasing the wrong command on duplicate IDs#801
MarkRose wants to merge 1 commit into
sm0svx:masterfrom
MarkRose:fix-cmdparser-removecmd-by-pointer

Conversation

@MarkRose

Copy link
Copy Markdown
Contributor
  • CmdParser::removeCmd() looked up the map entry to erase by command
    string only, without checking that the stored pointer matched the
    Command being removed. addCmd() refuses to overwrite an existing
    entry when two commands share the same command string, so the
    duplicate is never stored in the map. However, when that rejected
    duplicate is later deleted, its destructor calls removeCmd(this),
    which found the map entry by string, matched the original
    still-in-use command, and erased it. This silently unregistered a
    live command from the parser, leaving processCmd() unable to reach
    it anymore. Fixed by also comparing the mapped pointer against the
    Command instance being removed before erasing, so removeCmd() only
    ever removes its own entry.

Co-Authored-By: Claude Opus 4.8 [email protected]

- CmdParser::removeCmd() looked up the map entry to erase by command
  string only, without checking that the stored pointer matched the
  Command being removed. addCmd() refuses to overwrite an existing
  entry when two commands share the same command string, so the
  duplicate is never stored in the map. However, when that rejected
  duplicate is later deleted, its destructor calls removeCmd(this),
  which found the map entry by string, matched the *original*
  still-in-use command, and erased it. This silently unregistered a
  live command from the parser, leaving processCmd() unable to reach
  it anymore. Fixed by also comparing the mapped pointer against the
  Command instance being removed before erasing, so removeCmd() only
  ever removes its own entry.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@MarkRose MarkRose closed this Jul 12, 2026
@MarkRose MarkRose reopened this Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant