tests: Fix crash when getstarg() fails

Screwed up when test-suite-only command __cmd was added in commit
e852d45.  Should never happen with the intended use.  Fix it anyway.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
Markus Armbruster 2015-01-09 16:19:13 +01:00
parent b72f727b9b
commit 57fd96a7cf

View file

@ -27,7 +27,7 @@
* testing.c: Commands for test-suite use * testing.c: Commands for test-suite use
* *
* Known contributors to this file: * Known contributors to this file:
* Markus Armbruster, 2014 * Markus Armbruster, 2014-2015
*/ */
#include <config.h> #include <config.h>
@ -46,10 +46,16 @@ testing_cmd(void)
return RET_SYN; return RET_SYN;
if (!strcmp(p, "added")) { if (!strcmp(p, "added")) {
p = getstarg(player->argp[2], "number? ", buf); p = getstarg(player->argp[2], "number? ", buf);
if (!p || !*p)
return RET_SYN;
test_suite_prng_seed -= strtol(p, NULL, 10); test_suite_prng_seed -= strtol(p, NULL, 10);
p = getstarg(player->argp[3], "BTUs? ", buf); p = getstarg(player->argp[3], "BTUs? ", buf);
if (!p || !*p)
return RET_SYN;
player->btused -= strtol(p, NULL, 10); player->btused -= strtol(p, NULL, 10);
p = getstarg(player->argp[4], "money? ", buf); p = getstarg(player->argp[4], "money? ", buf);
if (!p)
return RET_SYN;
player->dolcost -= strtod(p, NULL); player->dolcost -= strtod(p, NULL);
return RET_OK; return RET_OK;
} }