[sr-dev] git:master:6390e8b3: rtpengine: Don't shm_str_dup() a NULL str->s

Stefan Mititelu stefan.mititelu at 1and1.ro
Thu Dec 10 12:55:06 CET 2015


Module: kamailio
Branch: master
Commit: 6390e8b35da0f8ad92430e40627d2c52e0b3ca52
URL: https://github.com/kamailio/kamailio/commit/6390e8b35da0f8ad92430e40627d2c52e0b3ca52

Author: Stefan Mititelu <stefan.mititelu at 1and1.ro>
Committer: Stefan Mititelu <stefan.mititelu at 1and1.ro>
Date: 2015-12-04T13:16:53+02:00

rtpengine: Don't shm_str_dup() a NULL str->s

Don't dup a NULL str->s to avoid warning message.
This happened usually when viabranch is not used(default being NULL).

---

Modified: modules/rtpengine/rtpengine.c

---

Diff:  https://github.com/kamailio/kamailio/commit/6390e8b35da0f8ad92430e40627d2c52e0b3ca52.diff
Patch: https://github.com/kamailio/kamailio/commit/6390e8b35da0f8ad92430e40627d2c52e0b3ca52.patch

---

diff --git a/modules/rtpengine/rtpengine.c b/modules/rtpengine/rtpengine.c
index 7fa3283..893bc9d 100644
--- a/modules/rtpengine/rtpengine.c
+++ b/modules/rtpengine/rtpengine.c
@@ -2360,17 +2360,21 @@ select_rtpp_node_new(str callid, str viabranch, int do_test)
         memset(entry, 0, sizeof(struct rtpengine_hash_entry));
 
 	/* fill the entry */
-	if (shm_str_dup(&entry->callid, &callid) < 0) {
-		LM_ERR("rtpengine hash table fail to duplicate calllen=%d callid=%.*s\n",
-			callid.len, callid.len, callid.s);
-		rtpengine_hash_table_free_entry(entry);
-		return node;
+        if (callid.s && callid.len > 0) {
+		if (shm_str_dup(&entry->callid, &callid) < 0) {
+			LM_ERR("rtpengine hash table fail to duplicate calllen=%d callid=%.*s\n",
+				callid.len, callid.len, callid.s);
+			rtpengine_hash_table_free_entry(entry);
+			return node;
+		}
 	}
-	if (shm_str_dup(&entry->viabranch, &viabranch) < 0) {
-		LM_ERR("rtpengine hash table fail to duplicate calllen=%d viabranch=%.*s\n",
-			callid.len, viabranch.len, viabranch.s);
-		rtpengine_hash_table_free_entry(entry);
-		return node;
+        if (viabranch.s && viabranch.len > 0) {
+		if (shm_str_dup(&entry->viabranch, &viabranch) < 0) {
+			LM_ERR("rtpengine hash table fail to duplicate calllen=%d viabranch=%.*s\n",
+				callid.len, viabranch.len, viabranch.s);
+			rtpengine_hash_table_free_entry(entry);
+			return node;
+		}
 	}
 	entry->node = node;
 	entry->next = NULL;




More information about the sr-dev mailing list