From 66e43caf9d83193575387429459e8ca09bf3db77 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 9 Nov 2015 20:03:38 +0100 Subject: [PATCH] CID 32303 Unchecked return value appeasing coverity --- src/magic.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/magic.c b/src/magic.c index ce69df78f..1873bb041 100644 --- a/src/magic.c +++ b/src/magic.c @@ -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,8 +2990,10 @@ 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); - cb_get_kv(match, &result, sizeof(result)); + result = 0; + if (cb_find_prefix(&cb_spellbooks, name, strlen(name), &match, 1, 0) > 0) { + cb_get_kv(match, &result, sizeof(result)); + } } return result; }