forked from github/server
Merge pull request #390 from ennorehling/develop
latest batch of coverity scan fixes
This commit is contained in:
commit
385a5dbe3a
5 changed files with 35 additions and 29 deletions
|
@ -1391,6 +1391,7 @@ int readgame(const char *filename, bool backup)
|
|||
storage store;
|
||||
stream strm;
|
||||
FILE *F;
|
||||
size_t sz;
|
||||
|
||||
init_locales();
|
||||
log_debug("- reading game data from %s\n", filename);
|
||||
|
@ -1405,8 +1406,8 @@ int readgame(const char *filename, bool backup)
|
|||
perror(path);
|
||||
return -1;
|
||||
}
|
||||
fread(&gdata.version, sizeof(int), 1, F);
|
||||
if (gdata.version >= INTPAK_VERSION) {
|
||||
sz = fread(&gdata.version, sizeof(int), 1, F);
|
||||
if (sz!=sizeof(int) || gdata.version >= INTPAK_VERSION) {
|
||||
int stream_version;
|
||||
size_t sz = fread(&stream_version, sizeof(int), 1, F);
|
||||
assert((sz==1 && stream_version == STREAM_VERSION) || !"unsupported data format");
|
||||
|
|
|
@ -208,6 +208,7 @@ newfaction *read_newfactions(const char *filename)
|
|||
nf = calloc(sizeof(newfaction), 1);
|
||||
if (set_email(&nf->email, email) != 0) {
|
||||
log_error("Invalid email address for subscription %s: %s\n", itoa36(subscription), email);
|
||||
free(nf);
|
||||
continue;
|
||||
}
|
||||
nf->password = _strdup(password);
|
||||
|
|
51
src/move.c
51
src/move.c
|
@ -2189,7 +2189,7 @@ static const region_list *travel_i(unit * u, const region_list * route_begin,
|
|||
static void travel(unit * u, region_list ** routep)
|
||||
{
|
||||
region *r = u->region;
|
||||
region_list *route_begin = NULL;
|
||||
region_list *route_begin;
|
||||
follower *followers = NULL;
|
||||
|
||||
assert(routep);
|
||||
|
@ -2232,36 +2232,37 @@ static void travel(unit * u, region_list ** routep)
|
|||
make_route(u, u->thisorder, routep);
|
||||
route_begin = *routep;
|
||||
|
||||
/* und ab die post: */
|
||||
travel_i(u, route_begin, NULL, u->thisorder, TRAVEL_NORMAL, &followers);
|
||||
if (route_begin) {
|
||||
/* und ab die post: */
|
||||
travel_i(u, route_begin, NULL, u->thisorder, TRAVEL_NORMAL, &followers);
|
||||
|
||||
/* followers */
|
||||
while (followers != NULL) {
|
||||
follower *fnext = followers->next;
|
||||
unit *uf = followers->uf;
|
||||
unit *ut = followers->ut;
|
||||
const region_list *route_end = followers->route_end;
|
||||
/* followers */
|
||||
while (followers != NULL) {
|
||||
follower *fnext = followers->next;
|
||||
unit *uf = followers->uf;
|
||||
unit *ut = followers->ut;
|
||||
const region_list *route_end = followers->route_end;
|
||||
|
||||
free(followers);
|
||||
followers = fnext;
|
||||
free(followers);
|
||||
followers = fnext;
|
||||
|
||||
if (uf->region == r) {
|
||||
order *follow_order;
|
||||
const struct locale *lang = u->faction->locale;
|
||||
const char *s = LOC(uf->faction->locale, parameters[P_UNIT]);
|
||||
/* construct an order */
|
||||
assert(s || !"missing translation for UNIT keyword");
|
||||
follow_order = create_order(K_FOLLOW, lang, "%s %i",
|
||||
s, ut->no);
|
||||
if (uf->region == r) {
|
||||
order *follow_order;
|
||||
const struct locale *lang = u->faction->locale;
|
||||
const char *s = LOC(uf->faction->locale, parameters[P_UNIT]);
|
||||
/* construct an order */
|
||||
assert(s || !"missing translation for UNIT keyword");
|
||||
follow_order = create_order(K_FOLLOW, lang, "%s %i",
|
||||
s, ut->no);
|
||||
|
||||
route_end = reroute(uf, route_begin, route_end);
|
||||
travel_i(uf, route_begin, route_end, follow_order, TRAVEL_FOLLOWING,
|
||||
&followers);
|
||||
caught_target(uf->region, uf);
|
||||
free_order(follow_order);
|
||||
route_end = reroute(uf, route_begin, route_end);
|
||||
travel_i(uf, route_begin, route_end, follow_order, TRAVEL_FOLLOWING,
|
||||
&followers);
|
||||
caught_target(uf->region, uf);
|
||||
free_order(follow_order);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void move_cmd(unit * u, bool move_on_land)
|
||||
|
|
|
@ -1033,7 +1033,7 @@ int sp_chaosrow(struct castorder * co)
|
|||
if (u_race(df->unit)->battle_flags & BF_NOBLOCK) {
|
||||
df->side->nonblockers[row] -= df->alive;
|
||||
}
|
||||
row = FIRST_ROW + (rng_int() % (LAST_ROW - FIRST_ROW));
|
||||
row = FIRST_ROW + (rng_int() % (NUMROWS - FIRST_ROW));
|
||||
switch (row) {
|
||||
case FIGHT_ROW:
|
||||
df->status = ST_FIGHT;
|
||||
|
|
|
@ -374,7 +374,10 @@ summary *make_summary(void)
|
|||
s->factions++;
|
||||
/* Problem mit Monsterpartei ... */
|
||||
if (!is_monsters(f)) {
|
||||
s->factionrace[old_race(f->race)]++;
|
||||
int rc = old_race(f->race);
|
||||
if (rc >= 0) {
|
||||
s->factionrace[rc]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue