[sofia-sip] Fix multiple issues reported by scan-build.

This commit is contained in:
Andrey Volk 2020-02-13 18:57:06 +04:00
parent 53c110ec51
commit 068f4c8524
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_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_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 n; /* Length of header contents */
isize_t name_len, xtra; isize_t name_len, xtra;
msg_header_t *h; 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, "\"\\"); size_t n = strcspn(s, "\"\\");
if (n == 0) { if (n == 0) {
if (e + 2 <= bsiz) if (b && e + 2 <= bsiz)
b[e] = '\\', b[e + 1] = s[0]; b[e] = '\\', b[e + 1] = s[0];
e += 2; e += 2;
s++; 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] = '"'; b[e] = '"';
e++; e++;

View File

@ -844,7 +844,7 @@ int nea_view_update(nea_server_t *nes,
nea_view_queue(nes, evv, evq); nea_view_queue(nes, evv, evq);
SU_DEBUG_7(("nea_server_update(%p): %s (%s)\n", (void *)nes, 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; 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 */ /* Duplicate the list bind to the transports */
new_via = sip_via_dup(self->sa_home, via); new_via = sip_via_dup(self->sa_home, via);
/* Duplicate the complete list shown to the application */ /* Duplicate the complete list shown to the application */
@ -3346,7 +3351,7 @@ void agent_recv_response(nta_agent_t *agent,
return; 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 */ /* Drop response messages to ACK */
agent->sa_stats->as_bad_response++; agent->sa_stats->as_bad_response++;
agent->sa_stats->as_bad_message++; agent->sa_stats->as_bad_message++;
@ -9160,7 +9165,7 @@ outgoing_remove_fork(nta_outgoing_t *orq)
nta_outgoing_t **slot; nta_outgoing_t **slot;
for (slot = &orq->orq_forking->orq_forks; for (slot = &orq->orq_forking->orq_forks;
*slot; slot && *slot;
slot = &(*slot)->orq_forks) { slot = &(*slot)->orq_forks) {
if (orq == *slot) { if (orq == *slot) {
*slot = orq->orq_forks; *slot = orq->orq_forks;

View File

@ -342,6 +342,13 @@ nth_site_t *nth_site_create(nth_site_t *parent,
size_t i, j; size_t i, j;
path = (char *)url->url_path; 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] == '/') while (path[0] == '/')
path++; path++;
@ -842,10 +849,10 @@ void server_request(server_t *srv,
if (subsite) if (subsite)
subsite->site_access = now; subsite->site_access = now;
else else if (site)
site->site_access = now; 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 */ /* Answer with 301 */
http_location_t loc[1]; http_location_t loc[1];
http_location_init(loc); 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); struct notifier_usage *nu = nua_dialog_usage_private(du);
//nua_client_request_t *cr = du->du_cr; //nua_client_request_t *cr = du->du_cr;
if (!nu)
return -1;
nu->nu_substate = nua_substate_terminated; nu->nu_substate = nua_substate_terminated;
#if 0 #if 0
if (cr) { if (cr) {

View File

@ -1122,7 +1122,7 @@ int nhp_save_params(nua_handle_t *nh,
su_home_t *home = nh->nh_home; su_home_t *home = nh->nh_home;
nua_t *nua = nh->nh_nua; nua_t *nua = nh->nh_nua;
nua_handle_t *dnh = nua->nua_dhandle; 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) { if (gsrc) {
*nua->nua_prefs = *gsrc; /* No pointers this far */ *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); ru = nua_dialog_usage_private(du);
if (!ru)
return;
if (ru->pending) if (ru->pending)
tport_release(ru->tport, ru->pending, NULL, NULL, nh, 0), ru->pending = 0; tport_release(ru->tport, ru->pending, NULL, NULL, nh, 0), ru->pending = 0;

View File

@ -3601,8 +3601,11 @@ int nua_update_server_respond(nua_server_request_t *sr, tagi_t const *tags)
sr_status(sr, SIP_500_INTERNAL_SERVER_ERROR); sr_status(sr, SIP_500_INTERNAL_SERVER_ERROR);
} }
else { else {
sr->sr_answer_sent = 1, ss->ss_oa_sent = Answer; sr->sr_answer_sent = 1;
ss->ss_sdp_version = soa_get_user_version(nh->nh_soa); if (ss) {
ss->ss_oa_sent = Answer;
ss->ss_sdp_version = soa_get_user_version(nh->nh_soa);
}
} }
} }

View File

@ -667,8 +667,10 @@ void nua_stack_signal(nua_t *nua, su_msg_r msg, nua_ee_data_t *ee)
} }
if (error < 0) { if (error < 0) {
nua_stack_event(nh->nh_nua, nh, NULL, event, if (nh) {
nua_stack_event(nh->nh_nua, nh, NULL, event,
NUA_ERROR_AT(__FILE__, __LINE__), NULL); NUA_ERROR_AT(__FILE__, __LINE__), NULL);
}
} }
su_msg_destroy(nua->nua_signal); 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)) if ((a != NULL) != (b != NULL))
return (a != NULL) < (b != NULL) ? -1 : 1; return (a != NULL) < (b != NULL) ? -1 : 1;
if (!a || !b)
return -1;
if (a->k_method != b->k_method) if (a->k_method != b->k_method)
return a->k_method < b->k_method ? -1 : 1; return a->k_method < b->k_method ? -1 : 1;
if (a->k_method == sdp_key_x && 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 */ /* Make transport parameter lowercase */
if (transport && strlen(transport) < (sizeof _transport)) { if (transport && strlen(transport) < (sizeof _transport)) {
char *s = strcpy(_transport, transport); char *s;
short c; short c;
strcpy(_transport, transport);
for (s = _transport; (c = *s) && c != ';'; s++) for (s = _transport; (c = *s) && c != ';'; s++)
if (isupper(c)) if (isupper(c))
*s = tolower(c); *s = tolower(c);

View File

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