Make generation numbers catch more potential yields on input
getstarg(), snxtitem() and snxtsct() can yield the processor, because they call getstring(). But only for null or empty arguments. For other arguments, we should call ef_make_stale(), to catch errors. Problem: if a caller never passes null or empty arguments, it may rely on these functions not yielding. We'd get false positives. In general, we can't know whether that's the case. But we do know in the common special case of player arguments. Call ef_make_stale() for those.
This commit is contained in:
parent
47b68a1c1f
commit
e3cf1e3280
6 changed files with 40 additions and 5 deletions
|
@ -202,6 +202,36 @@ status(void)
|
|||
return 1;
|
||||
}
|
||||
|
||||
/* Is ARG one of the player's last command's arguments? */
|
||||
static int
|
||||
is_command_arg(char *arg)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 1; i < 128 && player->argp[i]; i++) {
|
||||
if (arg == player->argp[i])
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Make all objects stale if ARG is one of the player's command arguments.
|
||||
* See ef_make_stale() for what "making stale" means.
|
||||
* Useful for functions that prompt for missing arguments.
|
||||
* These can yield the processor, so we'd like to call ef_make_stale()
|
||||
* there. Except that leads to false positives when the caller passes
|
||||
* an argument that is never null, and relies on the fact that the
|
||||
* function doesn't yield then. We can't know that in general. But
|
||||
* we do know in the common special case of command arguments.
|
||||
*/
|
||||
void
|
||||
make_stale_if_command_arg(char *arg)
|
||||
{
|
||||
if (is_command_arg(arg))
|
||||
ef_make_stale();
|
||||
}
|
||||
|
||||
/*
|
||||
* XXX This whole mess should be redone; execute block should
|
||||
* start with "exec start", and should end with "exec end".
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue