]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
test_sorcery_memory_cache_thrash: Handle error from vector append.
authorCorey Farrell <git@cfware.com>
Mon, 6 Nov 2017 23:33:13 +0000 (18:33 -0500)
committerCorey Farrell <git@cfware.com>
Mon, 6 Nov 2017 23:35:27 +0000 (18:35 -0500)
Cleanup resources when we fail to append the vector and report test
failure.

Change-Id: I6eb41586fd11dee8c0dfe35e91cb465a4cab7298

tests/test_sorcery_memory_cache_thrash.c

index c0d25feb3465605780071165afc9c2b10d3da94b..dfe7a7c81dea543d2a55b6fbf1af14f440c7e641 100644 (file)
@@ -218,7 +218,11 @@ static struct sorcery_memory_cache_thrash *sorcery_memory_cache_thrash_create(co
                /* This purposely holds no ref as the main thrash structure does */
                thread->sorcery = thrash->sorcery;
 
-               AST_VECTOR_APPEND(&thrash->threads, thread);
+               if (AST_VECTOR_APPEND(&thrash->threads, thread)) {
+                       ast_free(thread);
+                       ao2_ref(thrash, -1);
+                       return NULL;
+               }
        }
 
        return thrash;