From 08e14f3095c6feb62821dd3101d4b13bf6f503c9 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 14 Feb 2017 16:23:40 +0100 Subject: [PATCH] coverity warnings --- src/attributes/dict.c | 8 ++++++-- src/economy.c | 8 ++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/attributes/dict.c b/src/attributes/dict.c index ad66e3676..36d017b2c 100644 --- a/src/attributes/dict.c +++ b/src/attributes/dict.c @@ -132,8 +132,12 @@ static void dict_upgrade(attrib **alist, attrib *abegin) { ak = a_add(alist, a_new(&at_keys)); } } - ak->data.v = keys; - keys[0] = n + i; + if (ak) { + ak->data.v = keys; + if (keys) { + keys[0] = n + i; + } + } } attrib_type at_dict = { diff --git a/src/economy.c b/src/economy.c index dcbc7431e..dec4517a4 100644 --- a/src/economy.c +++ b/src/economy.c @@ -2707,7 +2707,7 @@ static void expandloot(region * r, request * lootorders) { unit *u; unsigned int i; - int looted = 0; + int m, looted = 0; int startmoney = rmoney(r); expandorders(r, lootorders); @@ -2724,9 +2724,9 @@ static void expandloot(region * r, request * lootorders) free(g_requests); /* Lowering morale by 1 depending on the looted money (+20%) */ - if (rng_int() % 100 < 20 + (looted * 80) / startmoney) { - int m = region_get_morale(r); - if (m) { + m = region_get_morale(r); + if (m && startmoney>0) { + if (rng_int() % 100 < 20 + (looted * 80) / startmoney) { /*Nur Moral -1, turns is not changed, so the first time nothing happens if the morale is good*/ region_set_morale(r, m - 1, -1); }