From 2246ce9d7aa08ac02a7833153e5661c40e8d1175 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 24 Aug 2014 12:40:00 +0200 Subject: [PATCH] segmentation fault caused by new getstrtoken semantics Conflicts: src/laws.c --- src/economy.c | 2 +- src/laws.c | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/economy.c b/src/economy.c index 8819f0fd4..86fb14a3d 100644 --- a/src/economy.c +++ b/src/economy.c @@ -2768,7 +2768,7 @@ static void breed_cmd(unit * u, struct order *ord) skip_token(); s = getstrtoken(); - m = atoi((const char *)s); + m = s ? atoi((const char *)s) : 0; if (m != 0) { /* first came a want-paramter */ s = getstrtoken(); diff --git a/src/laws.c b/src/laws.c index fe2ec329b..505dd91a7 100755 --- a/src/laws.c +++ b/src/laws.c @@ -3942,11 +3942,14 @@ void defaultorders(void) order *ord = *ordp; if (getkeyword(ord) == K_DEFAULT) { char lbuf[8192]; - order *new_order; - init_tokens(ord); - skip_token(); /* skip the keyword */ - strcpy(lbuf, getstrtoken()); - new_order = parse_order(lbuf, u->faction->locale); + order *new_order = 0; + const char *s; + init_order(ord); + s = getstrtoken(); + if (s) { + strcpy(lbuf, s); + new_order = parse_order(lbuf, u->faction->locale); + } *ordp = ord->next; ord->next = NULL; free_order(ord);