[sr-dev] git:5.1:61b9f621: usrloc: fix memory leak on DB_ONLY mode on RPC commands

Henning Westerholt hw at skalatan.de
Tue Jul 2 21:43:01 CEST 2019


Module: kamailio
Branch: 5.1
Commit: 61b9f621223c782a0710c7c589ebee9550b398f7
URL: https://github.com/kamailio/kamailio/commit/61b9f621223c782a0710c7c589ebee9550b398f7

Author: Victor Seva <linuxmaniac at torreviejawireless.org>
Committer: Henning Westerholt <hw at skalatan.de>
Date: 2019-07-02T21:42:49+02:00

usrloc: fix memory leak on DB_ONLY mode on RPC commands

(cherry picked from commit b97bb77265e7bfc5562a664e8a510692ed68b2f8)

---

Modified: src/modules/usrloc/ul_rpc.c

---

Diff:  https://github.com/kamailio/kamailio/commit/61b9f621223c782a0710c7c589ebee9550b398f7.diff
Patch: https://github.com/kamailio/kamailio/commit/61b9f621223c782a0710c7c589ebee9550b398f7.patch

---

diff --git a/src/modules/usrloc/ul_rpc.c b/src/modules/usrloc/ul_rpc.c
index b5522994d4..1398d9be2c 100644
--- a/src/modules/usrloc/ul_rpc.c
+++ b/src/modules/usrloc/ul_rpc.c
@@ -421,6 +421,7 @@ static void ul_rpc_lookup(rpc_t* rpc, void* ctx)
 
 	if (rpc->add(ctx, "{", &th) < 0)
 	{
+		release_urecord(rec);
 		unlock_udomain(dom, &aor);
 		rpc->fault(ctx, 500, "Internal error creating outer rpc");
 		return;
@@ -429,6 +430,7 @@ static void ul_rpc_lookup(rpc_t* rpc, void* ctx)
 				"AoR", &aor,
 				"Contacts", &ih)<0)
 	{
+		release_urecord(rec);
 		unlock_udomain(dom, &aor);
 		rpc->fault(ctx, 500, "Internal error creating aor struct");
 		return;
@@ -439,12 +441,13 @@ static void ul_rpc_lookup(rpc_t* rpc, void* ctx)
 		if (VALID_CONTACT( con, act_time)) {
 			rpl_tree++;
 			if (rpc_dump_contact(rpc, ctx, ih, con) == -1) {
+				release_urecord(rec);
 				unlock_udomain(dom, &aor);
 				return;
 			}
 		}
 	}
-
+	release_urecord(rec);
 	unlock_udomain( dom, &aor);
 
 	if (rpl_tree==0) {
@@ -533,17 +536,20 @@ static void ul_rpc_rm_contact(rpc_t* rpc, void* ctx)
 
 	ret = get_ucontact( rec, &contact, &rpc_ul_cid, &rpc_ul_path, RPC_UL_CSEQ+1, &con);
 	if (ret < 0) {
+		release_urecord(rec);
 		unlock_udomain( dom, &aor);
 		rpc->fault(ctx, 500, "Internal error (can't get contact)");
 		return;
 	}
 	if (ret > 0) {
+		release_urecord(rec);
 		unlock_udomain( dom, &aor);
 		rpc->fault(ctx, 404, "Contact not found");
 		return;
 	}
 
 	if (delete_ucontact(rec, con) < 0) {
+		release_urecord(rec);
 		unlock_udomain( dom, &aor);
 		rpc->fault(ctx, 500, "Internal error (can't delete contact)");
 		return;




More information about the sr-dev mailing list