Merge pull request #406 from signalwire/mod_dingaling

[mod_dingaling] scan-build: fix multiple dead assignments and dereference of null pointer.
This commit is contained in:
Andrey Volk 2020-02-22 00:48:08 +04:00 committed by GitHub
commit 14913244a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 17 deletions

View File

@ -499,7 +499,10 @@ static ldl_status parse_session_code(ldl_handle_t *handle, char *id, char *from,
unsigned int *candidate_len = NULL;
ldl_candidate_t (*candidates)[LDL_MAX_CANDIDATES] = NULL;
if ((key = iks_find_attrib(tag, "preference"))) {
if (!(key = iks_find_attrib(tag, "preference"))) {
globals.logger(DL_LOG_WARNING, "Field preference was not set\n");
continue;
} else {
unsigned int x;
pref = strtod(key, NULL);
@ -936,10 +939,10 @@ static int on_disco_default(void *user_data, ikspak *pak)
node = iks_find_attrib(pak->query, "node");
}
if (pak->subtype == IKS_TYPE_RESULT) {
if (pak && pak->subtype == IKS_TYPE_RESULT) {
globals.logger(DL_LOG_CRIT, "FixME!!! node=[%s]\n", node?node:"");
} else if (pak->subtype == IKS_TYPE_GET) {
if ((iq = iks_new("iq"))) {
} else if (pak && pak->subtype == IKS_TYPE_GET) {
if (ns && (iq = iks_new("iq"))) {
int all = 0;
iks_insert_attrib(iq, "from", handle->login);
@ -1081,7 +1084,6 @@ static int on_presence(void *user_data, ikspak *pak)
if (ext && strstr(ext, "voice-v1") && (buffer = apr_hash_get(handle->probe_hash, id, APR_HASH_KEY_STRING))) {
apr_cpystrn(buffer->buf, from, buffer->len);
buffer->hit = 1;
done = 1;
}
}
}
@ -1149,7 +1151,6 @@ static ldl_avatar_t *ldl_get_avatar(ldl_handle_t *handle, char *path, char *from
bytes = read(fd, image, sizeof(image));
close(fd);
fd = -1;
ap = malloc(sizeof(*ap));
assert(ap != NULL);
@ -2565,7 +2566,6 @@ unsigned int ldl_session_candidates(ldl_session_t *session,
iq = NULL;
sess = NULL;
tag = NULL;
x = 0;
id = 0;
}

View File

@ -680,7 +680,6 @@ static void roster_event_handler(switch_event_t *event)
{
char *status = switch_event_get_header(event, "status");
char *from = switch_event_get_header(event, "from");
char *event_type = switch_event_get_header(event, "event_type");
mdl_profile_t *profile = NULL;
switch_hash_index_t *hi;
void *val;
@ -694,10 +693,6 @@ static void roster_event_handler(switch_event_t *event)
status = NULL;
}
if (zstr(event_type)) {
event_type = "presence";
}
if (from) {
sql = switch_mprintf("select *,'%q' from jabber_subscriptions where sub_from='%q'", status ? status : "", from);
} else {
@ -4429,11 +4424,9 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
break;
case LDL_SIGNAL_CANDIDATES:
if (dl_signal) {
status = LDL_STATUS_SUCCESS;
status = parse_candidates(dlsession, session, LDL_TPORT_RTP, subject);
status = parse_candidates(dlsession, session, LDL_TPORT_VIDEO_RTP, subject);
status = parse_candidates(dlsession, session, LDL_TPORT_RTCP, subject);
parse_candidates(dlsession, session, LDL_TPORT_RTP, subject);
parse_candidates(dlsession, session, LDL_TPORT_VIDEO_RTP, subject);
parse_candidates(dlsession, session, LDL_TPORT_RTCP, subject);
status = parse_candidates(dlsession, session, LDL_TPORT_VIDEO_RTCP, subject);
}