Merge pull request #382 from ennorehling/develop

coverity scan fixes / help
This commit is contained in:
Enno Rehling 2015-11-09 20:20:43 +01:00
commit a2ac68197d
3 changed files with 9 additions and 5 deletions

View File

@ -2898,11 +2898,12 @@ static void expandloot(region * r, request * lootorders)
if (!norders)
return;
for (i = 0; i != norders && rmoney(r) > TAXFRACTION * 2; i++) {
for (i = 0; i != norders && startmoney > TAXFRACTION * 2; i++) {
change_money(oa[i].unit, TAXFRACTION);
oa[i].unit->n += TAXFRACTION;
/*Looting destroys double the money*/
rsetmoney(r, rmoney(r) - TAXFRACTION * 2);
startmoney = startmoney - TAXFRACTION * 2;
rsetmoney(r, startmoney);
looted = looted + TAXFRACTION * 2;
}
free(oa);

View File

@ -187,6 +187,7 @@ resource_type *rt_get_or_create(const char *name) {
else {
rtype->_name = _strdup(name);
rt_register(rtype);
return rt_find(name);
}
}
return rtype;

View File

@ -2978,7 +2978,7 @@ spellbook * get_spellbook(const char * name)
spellbook * result;
void * match;
if (cb_find_prefix(&cb_spellbooks, name, strlen(name), &match, 1, 0)) {
if (cb_find_prefix(&cb_spellbooks, name, strlen(name), &match, 1, 0) > 0) {
cb_get_kv(match, &result, sizeof(result));
}
else {
@ -2990,9 +2990,11 @@ spellbook * get_spellbook(const char * name)
log_error("cb_insert failed although cb_find returned nothing for spellbook=%s", name);
assert(!"should not happen");
}
cb_find_prefix(&cb_spellbooks, name, strlen(name), &match, 1, 0);
result = 0;
if (cb_find_prefix(&cb_spellbooks, name, strlen(name), &match, 1, 0) > 0) {
cb_get_kv(match, &result, sizeof(result));
}
}
return result;
}