From fed660987a26128b483b2981e2a91faa0281e7eb Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 9 Nov 2015 19:11:47 +0100 Subject: [PATCH] CID 22519 et al (resource leaks) make the failure case for get_spellbook a little slower, but make static analysis happy. --- src/magic.c | 2 ++ src/magic.test.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/magic.c b/src/magic.c index d65685aff..20fd47ccd 100644 --- a/src/magic.c +++ b/src/magic.c @@ -2985,6 +2985,8 @@ 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)); } return result; } diff --git a/src/magic.test.c b/src/magic.test.c index f356fa686..b208836f9 100644 --- a/src/magic.test.c +++ b/src/magic.test.c @@ -53,8 +53,9 @@ void test_spellbooks(CuTest * tc) test_cleanup(); herp = get_spellbook("herp"); - derp = get_spellbook("derp"); CuAssertPtrNotNull(tc, herp); + CuAssertPtrEquals(tc, herp, get_spellbook("herp")); + derp = get_spellbook("derp"); CuAssertPtrNotNull(tc, derp); CuAssertTrue(tc, derp != herp); CuAssertStrEquals(tc, "herp", herp->name);