[Asterisk-code-review] test sorcery memory cache thrash: Handle error from vector a... (asterisk[master])

Jenkins2 asteriskteam at digium.com
Tue Nov 7 17:32:49 CST 2017


Jenkins2 has submitted this change and it was merged. ( https://gerrit.asterisk.org/7064 )

Change subject: test_sorcery_memory_cache_thrash: Handle error from vector append.
......................................................................

test_sorcery_memory_cache_thrash: Handle error from vector append.

Cleanup resources when we fail to append the vector and report test
failure.

Change-Id: I6eb41586fd11dee8c0dfe35e91cb465a4cab7298
---
M tests/test_sorcery_memory_cache_thrash.c
1 file changed, 5 insertions(+), 1 deletion(-)

Approvals:
  Joshua Colp: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, but someone else must approve
  Richard Mudgett: Looks good to me, approved
  Jenkins2: Approved for Submit



diff --git a/tests/test_sorcery_memory_cache_thrash.c b/tests/test_sorcery_memory_cache_thrash.c
index c0d25fe..dfe7a7c 100644
--- a/tests/test_sorcery_memory_cache_thrash.c
+++ b/tests/test_sorcery_memory_cache_thrash.c
@@ -218,7 +218,11 @@
 		/* 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;

-- 
To view, visit https://gerrit.asterisk.org/7064
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I6eb41586fd11dee8c0dfe35e91cb465a4cab7298
Gerrit-Change-Number: 7064
Gerrit-PatchSet: 1
Gerrit-Owner: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20171107/7f9a357f/attachment.html>


More information about the asterisk-code-review mailing list