Fix crash in "document" command

PR cli/29800 points out that "document" will now crash when the
argument is an undefined command.  This is a regression due to the
"document user-defined aliases" patch.

Approved-By: Joel Brobecker <brobecker@adacore.com>
Reviewed-By: Philippe Waroquiers <philippe.waroquiers@skynet.be>
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29800
This commit is contained in:
Tom Tromey 2022-11-18 09:04:39 -07:00
parent 76cd77dc72
commit b70e9270fb
2 changed files with 6 additions and 0 deletions

View file

@ -1515,6 +1515,8 @@ do_document_command (const char *comname, int from_tty,
validate_comname (&comname);
lookup_cmd_composition (comfull, &alias, &prefix_cmd, &c);
if (c == nullptr)
error (_("Undefined command: \"%s\"."), comfull);
if (c->theclass != class_user
&& (alias == nullptr || alias->theclass != class_alias))