[Asterisk-code-review] res sorcery realtime.c: Fix ref leak if object failed to apply. (asterisk[13])

Richard Mudgett asteriskteam at digium.com
Fri Feb 2 17:45:05 CST 2018


Richard Mudgett has uploaded this change for review. ( https://gerrit.asterisk.org/8152


Change subject: res_sorcery_realtime.c: Fix ref leak if object failed to apply.
......................................................................

res_sorcery_realtime.c: Fix ref leak if object failed to apply.

Change-Id: I3c7106ff77009754725cee790eadf5da44154ab6
---
M res/res_sorcery_realtime.c
1 file changed, 4 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/52/8152/1

diff --git a/res/res_sorcery_realtime.c b/res/res_sorcery_realtime.c
index 9b0b25f..c74e1c1 100644
--- a/res/res_sorcery_realtime.c
+++ b/res/res_sorcery_realtime.c
@@ -178,6 +178,7 @@
 	if (!id
 		|| !(object = ast_sorcery_alloc(sorcery, type, id->value))
 		|| ast_sorcery_objectset_apply(sorcery, object, objectset)) {
+		ao2_cleanup(object);
 		return NULL;
 	}
 
@@ -235,7 +236,9 @@
 
 		objectset = sorcery_realtime_filter_objectset(objectset, &id, sorcery, type);
 
-		if (id && (object = ast_sorcery_alloc(sorcery, type, id->value)) && !ast_sorcery_objectset_apply(sorcery, object, objectset)) {
+		if (id
+			&& (object = ast_sorcery_alloc(sorcery, type, id->value))
+			&& !ast_sorcery_objectset_apply(sorcery, object, objectset)) {
 			ao2_link(objects, object);
 		}
 

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

Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: newchange
Gerrit-Change-Id: I3c7106ff77009754725cee790eadf5da44154ab6
Gerrit-Change-Number: 8152
Gerrit-PatchSet: 1
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180202/799c1de3/attachment.html>


More information about the asterisk-code-review mailing list