loader command interpreter should reset command_errmsg

The command interpreter does leave command_errmsg as is after printing its
content, assuming the next command will reset it in bf_command(). However,
in case the forth native word is defined as builtin, the bf_command is not
used and forth words will also end up the command_errmsg content printed.

Since command_errmsg is pointer to actual error message, which can be static
read only string, we can not just set *command_errmsg = '\0', instead we need
to reset the pointer itself.

Illumos issue: https://www.illumos.org/issues/7405

Reported by: Igor Kozhukhov.
Reviewed by:	allanjude
Approved by:	allanjude (mentor)
Differential Revision:	https://reviews.freebsd.org/D8032
This commit is contained in:
Toomas Soome 2016-09-27 20:40:44 +00:00
parent 040b30497c
commit 92a85eb9d7
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=306380

View File

@ -325,13 +325,15 @@ bf_run(char *line)
printf("Parse error!\n");
break;
default:
/* Hopefully, all other codes filled this buffer */
printf("%s\n", command_errmsg);
if (command_errmsg != NULL) {
printf("%s\n", command_errmsg);
command_errmsg = NULL;
}
}
if (result == VM_USEREXIT)
panic("interpreter exit");
setenv("interpret", bf_vm->state ? "" : "OK", 1);
return result;
return (result);
}