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) if (!norders)
return; 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); change_money(oa[i].unit, TAXFRACTION);
oa[i].unit->n += TAXFRACTION; oa[i].unit->n += TAXFRACTION;
/*Looting destroys double the money*/ /*Looting destroys double the money*/
rsetmoney(r, rmoney(r) - TAXFRACTION * 2); startmoney = startmoney - TAXFRACTION * 2;
rsetmoney(r, startmoney);
looted = looted + TAXFRACTION * 2; looted = looted + TAXFRACTION * 2;
} }
free(oa); free(oa);

View File

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

View File

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