forked from github/server
fix renumber parser crash
This commit is contained in:
parent
5a7e8cbd9a
commit
b7275e40f3
2 changed files with 8 additions and 3 deletions
|
@ -164,7 +164,7 @@ int renumber_cmd(unit * u, order * ord)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
s = gettoken(token, sizeof(token));
|
s = gettoken(token, sizeof(token));
|
||||||
if (*s == 0) {
|
if (s == NULL || *s == 0) {
|
||||||
i = newcontainerid();
|
i = newcontainerid();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -100,7 +100,12 @@ static void test_renumber_building(CuTest *tc) {
|
||||||
no = u->building->no;
|
no = u->building->no;
|
||||||
uno = (no > 1) ? no - 1 : no + 1;
|
uno = (no > 1) ? no - 1 : no + 1;
|
||||||
lang = u->faction->locale;
|
lang = u->faction->locale;
|
||||||
u->thisorder = create_order(K_NUMBER, lang, "%s %s", LOC(lang, parameters[P_BUILDING]), itoa36(uno));
|
u->thisorder = create_order(K_NUMBER, lang, LOC(lang, parameters[P_BUILDING]));
|
||||||
|
renumber_cmd(u, u->thisorder);
|
||||||
|
CuAssertTrue(tc, no != u->building->no);
|
||||||
|
free_order(u->thisorder);
|
||||||
|
|
||||||
|
u->thisorder = create_order(K_NUMBER, lang, "%s %i", LOC(lang, parameters[P_BUILDING]), uno);
|
||||||
renumber_cmd(u, u->thisorder);
|
renumber_cmd(u, u->thisorder);
|
||||||
CuAssertIntEquals(tc, uno, u->building->no);
|
CuAssertIntEquals(tc, uno, u->building->no);
|
||||||
test_teardown();
|
test_teardown();
|
||||||
|
@ -119,7 +124,7 @@ static void test_renumber_building_duplicate(CuTest *tc) {
|
||||||
u->building = test_create_building(u->region, NULL);
|
u->building = test_create_building(u->region, NULL);
|
||||||
no = u->building->no;
|
no = u->building->no;
|
||||||
lang = f->locale;
|
lang = f->locale;
|
||||||
u->thisorder = create_order(K_NUMBER, lang, "%s %s", LOC(lang, parameters[P_BUILDING]), itoa36(uno));
|
u->thisorder = create_order(K_NUMBER, lang, "%s %i", LOC(lang, parameters[P_BUILDING]), uno);
|
||||||
renumber_cmd(u, u->thisorder);
|
renumber_cmd(u, u->thisorder);
|
||||||
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error115"));
|
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error115"));
|
||||||
CuAssertIntEquals(tc, no, u->building->no);
|
CuAssertIntEquals(tc, no, u->building->no);
|
||||||
|
|
Loading…
Reference in a new issue