Merge pull request #352 from signalwire/sofia_scanbuild

[sofia-sip] Fix multiple issues reported by scan-build.
This commit is contained in:
Andrey Volk 2020-02-14 01:29:16 +04:00 committed by GitHub
commit 25fc9fc6dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 46 additions and 14 deletions

View File

@ -1 +1 @@
Wed Feb 12 22:23:00 UTC 2020
Thu Feb 13 14:53:01 UTC 2020

View File

@ -1244,7 +1244,7 @@ issize_t msg_parse_next_field(su_home_t *home, msg_header_t *prev,
msg_header_t *msg_header_d(su_home_t *home, msg_t const *msg, char const *b)
{
msg_mclass_t const *mc = msg->m_class;
msg_href_t const *hr = mc->mc_unknown;
msg_href_t const *hr;
isize_t n; /* Length of header contents */
isize_t name_len, xtra;
msg_header_t *h;

View File

@ -1756,7 +1756,7 @@ issize_t msg_unquoted_e(char *b, isize_t bsiz, char const *s)
size_t n = strcspn(s, "\"\\");
if (n == 0) {
if (e + 2 <= bsiz)
if (b && e + 2 <= bsiz)
b[e] = '\\', b[e + 1] = s[0];
e += 2;
s++;
@ -1769,7 +1769,7 @@ issize_t msg_unquoted_e(char *b, isize_t bsiz, char const *s)
}
}
if (e < bsiz)
if (b && e < bsiz)
b[e] = '"';
e++;

View File

@ -844,7 +844,7 @@ int nea_view_update(nea_server_t *nes,
nea_view_queue(nes, evv, evq);
SU_DEBUG_7(("nea_server_update(%p): %s (%s)\n", (void *)nes,
ev->ev_event->o_type, evv->evv_content_type->c_type));
ev->ev_event->o_type, (evv->evv_content_type ? evv->evv_content_type->c_type : "N/A")));
return 1;
}

View File

@ -2406,6 +2406,11 @@ int agent_init_via(nta_agent_t *self, tport_t *primaries, int use_maddr)
}
}
if (!via) {
SU_DEBUG_9(("nta: agent_init_via failed\n" VA_NONE));
goto error;
}
/* Duplicate the list bind to the transports */
new_via = sip_via_dup(self->sa_home, via);
/* Duplicate the complete list shown to the application */
@ -3346,7 +3351,7 @@ void agent_recv_response(nta_agent_t *agent,
return;
}
if (sip->sip_cseq->cs_method == sip_method_ack) {
if (sip->sip_cseq && sip->sip_cseq->cs_method == sip_method_ack) {
/* Drop response messages to ACK */
agent->sa_stats->as_bad_response++;
agent->sa_stats->as_bad_message++;
@ -9160,7 +9165,7 @@ outgoing_remove_fork(nta_outgoing_t *orq)
nta_outgoing_t **slot;
for (slot = &orq->orq_forking->orq_forks;
*slot;
slot && *slot;
slot = &(*slot)->orq_forks) {
if (orq == *slot) {
*slot = orq->orq_forks;

View File

@ -342,6 +342,13 @@ nth_site_t *nth_site_create(nth_site_t *parent,
size_t i, j;
path = (char *)url->url_path;
if (!path) {
SU_DEBUG_3(("nth_site_create(): invalid url\n" VA_NONE));
errno = EINVAL;
goto error;
}
while (path[0] == '/')
path++;
@ -842,10 +849,10 @@ void server_request(server_t *srv,
if (subsite)
subsite->site_access = now;
else
else if (site)
site->site_access = now;
if (subsite && subsite->site_isdir && subpath == site_nodir_match) {
if (site && subsite && subsite->site_isdir && subpath == site_nodir_match) {
/* Answer with 301 */
http_location_t loc[1];
http_location_init(loc);

View File

@ -853,6 +853,9 @@ static int nua_notify_usage_shutdown(nua_handle_t *nh,
struct notifier_usage *nu = nua_dialog_usage_private(du);
//nua_client_request_t *cr = du->du_cr;
if (!nu)
return -1;
nu->nu_substate = nua_substate_terminated;
#if 0
if (cr) {

View File

@ -1122,7 +1122,7 @@ int nhp_save_params(nua_handle_t *nh,
su_home_t *home = nh->nh_home;
nua_t *nua = nh->nh_nua;
nua_handle_t *dnh = nua->nua_dhandle;
nua_handle_preferences_t *dst = nh->nh_prefs, old[1];
nua_handle_preferences_t *dst, old[1];
if (gsrc) {
*nua->nua_prefs = *gsrc; /* No pointers this far */

View File

@ -86,6 +86,9 @@ static void nua_registrar_usage_remove(nua_handle_t *nh,
ru = nua_dialog_usage_private(du);
if (!ru)
return;
if (ru->pending)
tport_release(ru->tport, ru->pending, NULL, NULL, nh, 0), ru->pending = 0;

View File

@ -3601,10 +3601,13 @@ int nua_update_server_respond(nua_server_request_t *sr, tagi_t const *tags)
sr_status(sr, SIP_500_INTERNAL_SERVER_ERROR);
}
else {
sr->sr_answer_sent = 1, ss->ss_oa_sent = Answer;
sr->sr_answer_sent = 1;
if (ss) {
ss->ss_oa_sent = Answer;
ss->ss_sdp_version = soa_get_user_version(nh->nh_soa);
}
}
}
if (ss && 200 <= sr->sr_status && sr->sr_status < 300) {
session_timer_preferences(ss->ss_timer,

View File

@ -667,9 +667,11 @@ void nua_stack_signal(nua_t *nua, su_msg_r msg, nua_ee_data_t *ee)
}
if (error < 0) {
if (nh) {
nua_stack_event(nh->nh_nua, nh, NULL, event,
NUA_ERROR_AT(__FILE__, __LINE__), NULL);
}
}
su_msg_destroy(nua->nua_signal);
}

View File

@ -1370,6 +1370,9 @@ int sdp_key_cmp(sdp_key_t const *a, sdp_key_t const *b)
if ((a != NULL) != (b != NULL))
return (a != NULL) < (b != NULL) ? -1 : 1;
if (!a || !b)
return -1;
if (a->k_method != b->k_method)
return a->k_method < b->k_method ? -1 : 1;
if (a->k_method == sdp_key_x &&

View File

@ -257,9 +257,11 @@ sip_contact_string_from_via(su_home_t *home,
/* Make transport parameter lowercase */
if (transport && strlen(transport) < (sizeof _transport)) {
char *s = strcpy(_transport, transport);
char *s;
short c;
strcpy(_transport, transport);
for (s = _transport; (c = *s) && c != ';'; s++)
if (isupper(c))
*s = tolower(c);

View File

@ -228,11 +228,15 @@ int su_getlocalinfo(su_localinfo_t const *hints,
#endif
case AF_INET:
#ifndef USE_LOCALINFO0
ip4 = 1;
#endif
break;
case 0:
#ifndef USE_LOCALINFO0
ip4 = 1;
#endif
#if SU_HAVE_IN6
ip6 = 1;
#endif