From 6390e8b35da0f8ad92430e40627d2c52e0b3ca52 Mon Sep 17 00:00:00 2001 From: Stefan Mititelu Date: Fri, 4 Dec 2015 13:08:11 +0200 Subject: [PATCH] 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). --- modules/rtpengine/rtpengine.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/modules/rtpengine/rtpengine.c b/modules/rtpengine/rtpengine.c index 7fa328365f8..893bc9dd67f 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;