浏览代码

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).
Stefan Mititelu 9 年之前
父节点
当前提交
6390e8b35d
共有 1 个文件被更改,包括 14 次插入10 次删除
  1. 14 10
      modules/rtpengine/rtpengine.c

+ 14 - 10
modules/rtpengine/rtpengine.c

@@ -2360,17 +2360,21 @@ found:
         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;