From 851a3bb7788b0a154e8fdb9fa4f150fa0777e8b5 Mon Sep 17 00:00:00 2001 From: Stefan Mititelu Date: Mon, 23 Nov 2015 12:35:03 +0200 Subject: [PATCH] p_usrloc: str->s string NULL check before str_dup Don't shm_str_dup() NULL str->s strings. Add checks to avoid shm_str_dup() warning. --- modules/p_usrloc/ucontact.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/modules/p_usrloc/ucontact.c b/modules/p_usrloc/ucontact.c index cdce6dd5aad..f37c16046d9 100644 --- a/modules/p_usrloc/ucontact.c +++ b/modules/p_usrloc/ucontact.c @@ -60,20 +60,31 @@ ucontact_t* new_ucontact(str* _dom, str* _aor, str* _contact, ucontact_info_t* _ } memset(c, 0, sizeof(ucontact_t)); - if (shm_str_dup( &c->c, _contact) < 0) goto error; - if (shm_str_dup( &c->callid, _ci->callid) < 0) goto error; - if (shm_str_dup( &c->user_agent, _ci->user_agent) < 0) goto error; + if (_contact->s && _contact->len > 0) { + if (shm_str_dup( &c->c, _contact) < 0) goto error; + } - if (_ci->received.s && _ci->received.len) { + if (_ci->callid->s && _ci->callid->len > 0) { + if (shm_str_dup( &c->callid, _ci->callid) < 0) goto error; + } + + if (_ci->user_agent->s && _ci->user_agent->len > 0) { + if (shm_str_dup( &c->user_agent, _ci->user_agent) < 0) goto error; + } + + if (_ci->received.s && _ci->received.len > 0) { if (shm_str_dup( &c->received, &_ci->received) < 0) goto error; } - if (_ci->path && _ci->path->len) { + + if (_ci->path && _ci->path->len > 0) { if (shm_str_dup( &c->path, _ci->path) < 0) goto error; } - if (_ci->ruid.s && _ci->ruid.len) { + + if (_ci->ruid.s && _ci->ruid.len > 0) { if (shm_str_dup( &c->ruid, &_ci->ruid) < 0) goto error; } - if (_ci->instance.s && _ci->instance.len) { + + if (_ci->instance.s && _ci->instance.len > 0) { if (shm_str_dup( &c->instance, &_ci->instance) < 0) goto error; }