From 5082454c457d6a00f527bfef6e02ccb1c733401d Mon Sep 17 00:00:00 2001 From: Andrey Volk Date: Sat, 22 Feb 2020 00:33:13 +0400 Subject: [PATCH] [mod_dingaling] scan-build: fix multiple dead assignments and dereference of null pointer. --- libs/libdingaling/src/libdingaling.c | 14 +++++++------- src/mod/endpoints/mod_dingaling/mod_dingaling.c | 13 +++---------- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/libs/libdingaling/src/libdingaling.c b/libs/libdingaling/src/libdingaling.c index 8efe5c4af5..07e70d0c50 100644 --- a/libs/libdingaling/src/libdingaling.c +++ b/libs/libdingaling/src/libdingaling.c @@ -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; } diff --git a/src/mod/endpoints/mod_dingaling/mod_dingaling.c b/src/mod/endpoints/mod_dingaling/mod_dingaling.c index 8ab56c5da1..99a6587409 100644 --- a/src/mod/endpoints/mod_dingaling/mod_dingaling.c +++ b/src/mod/endpoints/mod_dingaling/mod_dingaling.c @@ -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); }