segmentation fault caused by new getstrtoken semantics

This commit is contained in:
Enno Rehling 2014-08-24 12:40:00 +02:00
parent 86c2096cfa
commit 1c069da921
2 changed files with 8 additions and 4 deletions

View File

@ -2766,7 +2766,7 @@ static void breed_cmd(unit * u, struct order *ord)
(void)init_order(ord); (void)init_order(ord);
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

@ -3923,10 +3923,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;
const char *s;
init_order(ord); 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);