forked from github/server
fix remaining getstrtoken uses without null-check.
This commit is contained in:
parent
a5961d069c
commit
74582aeb2f
|
@ -22,8 +22,8 @@ exit $2 # otherwise
|
||||||
function build() {
|
function build() {
|
||||||
assert_dir $SOURCE
|
assert_dir $SOURCE
|
||||||
cd $SOURCE
|
cd $SOURCE
|
||||||
git pull || abort "failed to update source. do you have local changes?"
|
|
||||||
[ -z $1 ] || git checkout $1
|
[ -z $1 ] || git checkout $1
|
||||||
|
git pull || abort "failed to update source. do you have local changes?"
|
||||||
s/build || abort "build failed."
|
s/build || abort "build failed."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1820,7 +1820,8 @@ int make_cmd(unit * u, struct order *ord)
|
||||||
cmistake(u, ord, 275, MSG_PRODUCE);
|
cmistake(u, ord, 275, MSG_PRODUCE);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
direction_t d = get_direction(getstrtoken(), u->faction->locale);
|
const char * s = getstrtoken();
|
||||||
|
direction_t d = s ? get_direction(s, u->faction->locale) : NODIRECTION;
|
||||||
if (d != NODIRECTION) {
|
if (d != NODIRECTION) {
|
||||||
build_road(r, u, m, d);
|
build_road(r, u, m, d);
|
||||||
}
|
}
|
||||||
|
@ -2058,6 +2059,7 @@ static void buy(unit * u, request ** buyorders, struct order *ord)
|
||||||
const item_type *itype = NULL;
|
const item_type *itype = NULL;
|
||||||
const luxury_type *ltype = NULL;
|
const luxury_type *ltype = NULL;
|
||||||
keyword_t kwd;
|
keyword_t kwd;
|
||||||
|
const char *s;
|
||||||
|
|
||||||
if (u->ship && is_guarded(r, u, GUARD_CREWS)) {
|
if (u->ship && is_guarded(r, u, GUARD_CREWS)) {
|
||||||
cmistake(u, ord, 69, MSG_INCOME);
|
cmistake(u, ord, 69, MSG_INCOME);
|
||||||
|
@ -2133,7 +2135,8 @@ static void buy(unit * u, request ** buyorders, struct order *ord)
|
||||||
/* die Menge der verkauften Güter merken */
|
/* die Menge der verkauften Güter merken */
|
||||||
a->data.i += n;
|
a->data.i += n;
|
||||||
|
|
||||||
itype = finditemtype(getstrtoken(), u->faction->locale);
|
s = getstrtoken();
|
||||||
|
itype = s ? finditemtype(s, u->faction->locale) : 0;
|
||||||
if (itype != NULL) {
|
if (itype != NULL) {
|
||||||
ltype = resource2luxury(itype->rtype);
|
ltype = resource2luxury(itype->rtype);
|
||||||
if (ltype == NULL) {
|
if (ltype == NULL) {
|
||||||
|
|
14
src/items.c
14
src/items.c
|
@ -35,16 +35,19 @@ use_studypotion(struct unit *u, const struct item_type *itype, int amount,
|
||||||
struct order *ord)
|
struct order *ord)
|
||||||
{
|
{
|
||||||
if (init_order(u->thisorder) == K_STUDY) {
|
if (init_order(u->thisorder) == K_STUDY) {
|
||||||
skill_t sk;
|
skill_t sk = NOSKILL;
|
||||||
skill *sv;
|
skill *sv = 0;
|
||||||
|
const char * s = getstrtoken();
|
||||||
|
|
||||||
sk = get_skill(getstrtoken(), u->faction->locale);
|
if (s) {
|
||||||
|
sk = get_skill(s, u->faction->locale);
|
||||||
sv = unit_skill(u, sk);
|
sv = unit_skill(u, sk);
|
||||||
|
}
|
||||||
|
|
||||||
if (sv && sv->level > 2) {
|
if (sv && sv->level > 2) {
|
||||||
/* TODO: message */
|
/* TODO: message */
|
||||||
}
|
}
|
||||||
else if (study_cost(u, sk) > 0) {
|
else if (sk!=NOSKILL && study_cost(u, sk) > 0) {
|
||||||
/* TODO: message */
|
/* TODO: message */
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -54,8 +57,9 @@ struct order *ord)
|
||||||
a = a_add(&u->attribs, a_new(&at_learning));
|
a = a_add(&u->attribs, a_new(&at_learning));
|
||||||
}
|
}
|
||||||
teach = (teaching_info *)a->data.v;
|
teach = (teaching_info *)a->data.v;
|
||||||
if (amount > MAXGAIN)
|
if (amount > MAXGAIN) {
|
||||||
amount = MAXGAIN;
|
amount = MAXGAIN;
|
||||||
|
}
|
||||||
teach->value += amount * 30;
|
teach->value += amount * 30;
|
||||||
if (teach->value > MAXGAIN * 30) {
|
if (teach->value > MAXGAIN * 30) {
|
||||||
teach->value = MAXGAIN * 30;
|
teach->value = MAXGAIN * 30;
|
||||||
|
|
|
@ -90,15 +90,21 @@ ship *getship(const struct region * r)
|
||||||
|
|
||||||
static void destroy_road(unit * u, int nmax, struct order *ord)
|
static void destroy_road(unit * u, int nmax, struct order *ord)
|
||||||
{
|
{
|
||||||
direction_t d = get_direction(getstrtoken(), u->faction->locale);
|
const char *s = getstrtoken();
|
||||||
|
direction_t d = s ? get_direction(s, u->faction->locale) : NODIRECTION;
|
||||||
|
if (d == NODIRECTION) {
|
||||||
|
/* Die Richtung wurde nicht erkannt */
|
||||||
|
cmistake(u, ord, 71, MSG_PRODUCE);
|
||||||
|
} else {
|
||||||
unit *u2;
|
unit *u2;
|
||||||
region *r = u->region;
|
region *r = u->region;
|
||||||
short n = (short)nmax;
|
short road, n = (short)nmax;
|
||||||
|
|
||||||
if (nmax > SHRT_MAX)
|
if (nmax > SHRT_MAX) {
|
||||||
n = SHRT_MAX;
|
n = SHRT_MAX;
|
||||||
else if (nmax < 0)
|
} else if (nmax < 0) {
|
||||||
n = 0;
|
n = 0;
|
||||||
|
}
|
||||||
|
|
||||||
for (u2 = r->units; u2; u2 = u2->next) {
|
for (u2 = r->units; u2; u2 = u2->next) {
|
||||||
if (u2->faction != u->faction && is_guard(u2, GUARD_TAX)
|
if (u2->faction != u->faction && is_guard(u2, GUARD_TAX)
|
||||||
|
@ -109,11 +115,7 @@ static void destroy_road(unit * u, int nmax, struct order *ord)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (d == NODIRECTION) {
|
road = rroad(r, d);
|
||||||
/* Die Richtung wurde nicht erkannt */
|
|
||||||
cmistake(u, ord, 71, MSG_PRODUCE);
|
|
||||||
} else {
|
|
||||||
short road = rroad(r, d);
|
|
||||||
n = _min(n, road);
|
n = _min(n, road);
|
||||||
if (n != 0) {
|
if (n != 0) {
|
||||||
region *r2 = rconnect(r, d);
|
region *r2 = rconnect(r, d);
|
||||||
|
|
|
@ -1127,7 +1127,8 @@ unsigned int getuint(void)
|
||||||
|
|
||||||
int getint(void)
|
int getint(void)
|
||||||
{
|
{
|
||||||
return atoi(getstrtoken());
|
const char * s = getstrtoken();
|
||||||
|
return s ? atoi(s) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct race *findrace(const char *s, const struct locale *lang)
|
const struct race *findrace(const char *s, const struct locale *lang)
|
||||||
|
@ -1199,7 +1200,8 @@ bool isparam(const char *s, const struct locale * lang, param_t param)
|
||||||
|
|
||||||
param_t getparam(const struct locale * lang)
|
param_t getparam(const struct locale * lang)
|
||||||
{
|
{
|
||||||
return findparam(getstrtoken(), lang);
|
const char *s = getstrtoken();
|
||||||
|
return s ? findparam(s, lang) : NOPARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
faction *findfaction(int n)
|
faction *findfaction(int n)
|
||||||
|
|
|
@ -2127,9 +2127,10 @@ int mail_cmd(unit * u, struct order *ord)
|
||||||
int banner_cmd(unit * u, struct order *ord)
|
int banner_cmd(unit * u, struct order *ord)
|
||||||
{
|
{
|
||||||
init_order(ord);
|
init_order(ord);
|
||||||
|
const char * s = getstrtoken();
|
||||||
|
|
||||||
free(u->faction->banner);
|
free(u->faction->banner);
|
||||||
u->faction->banner = _strdup(getstrtoken());
|
u->faction->banner = s ? _strdup(s) : 0;
|
||||||
add_message(&u->faction->msgs, msg_message("changebanner", "value",
|
add_message(&u->faction->msgs, msg_message("changebanner", "value",
|
||||||
u->faction->banner));
|
u->faction->banner));
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
static skill_t getskill(const struct locale *lang)
|
static skill_t getskill(const struct locale *lang)
|
||||||
{
|
{
|
||||||
return get_skill(getstrtoken(), lang);
|
const char * s = getstrtoken();
|
||||||
|
return s ? get_skill(s, lang) : NOSKILL;
|
||||||
}
|
}
|
||||||
|
|
||||||
magic_t getmagicskill(const struct locale * lang)
|
magic_t getmagicskill(const struct locale * lang)
|
||||||
|
|
Loading…
Reference in New Issue