segmentation fault caused by new getstrtoken semantics

Conflicts:
	src/laws.c
This commit is contained in:
Enno Rehling 2014-08-24 12:40:00 +02:00
parent 87720c2b9c
commit 2246ce9d7a
2 changed files with 9 additions and 6 deletions

View File

@ -2768,7 +2768,7 @@ static void breed_cmd(unit * u, struct order *ord)
skip_token(); skip_token();
s = getstrtoken(); s = getstrtoken();
m = atoi((const char *)s); m = s ? atoi((const char *)s) : 0;
if (m != 0) { if (m != 0) {
/* first came a want-paramter */ /* first came a want-paramter */
s = getstrtoken(); s = getstrtoken();

View File

@ -3942,11 +3942,14 @@ void defaultorders(void)
order *ord = *ordp; order *ord = *ordp;
if (getkeyword(ord) == K_DEFAULT) { if (getkeyword(ord) == K_DEFAULT) {
char lbuf[8192]; char lbuf[8192];
order *new_order; order *new_order = 0;
init_tokens(ord); const char *s;
skip_token(); /* skip the keyword */ init_order(ord);
strcpy(lbuf, getstrtoken()); s = getstrtoken();
new_order = parse_order(lbuf, u->faction->locale); if (s) {
strcpy(lbuf, s);
new_order = parse_order(lbuf, u->faction->locale);
}
*ordp = ord->next; *ordp = ord->next;
ord->next = NULL; ord->next = NULL;
free_order(ord); free_order(ord);