FS-11903: Fix errors reported by PVS-Studio Static Code Analyzer for switch_event.c
This commit is contained in:
parent
6ee5ad8b83
commit
863390ebba
|
@ -955,16 +955,13 @@ SWITCH_DECLARE(int) switch_event_add_array(switch_event_t *event, const char *va
|
||||||
p += 2;
|
p += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!max) {
|
|
||||||
return -2;
|
|
||||||
}
|
|
||||||
|
|
||||||
data = strdup(val + 7);
|
data = strdup(val + 7);
|
||||||
|
|
||||||
len = (sizeof(char *) * max) + 1;
|
len = (sizeof(char *) * max) + 1;
|
||||||
switch_assert(len);
|
switch_assert(len);
|
||||||
|
|
||||||
array = malloc(len);
|
array = malloc(len);
|
||||||
|
switch_assert(array);
|
||||||
memset(array, 0, len);
|
memset(array, 0, len);
|
||||||
|
|
||||||
switch_separate_string_string(data, "|:", array, max);
|
switch_separate_string_string(data, "|:", array, max);
|
||||||
|
@ -1565,12 +1562,12 @@ SWITCH_DECLARE(switch_status_t) switch_event_serialize(switch_event_t *event, ch
|
||||||
llen = strlen(hp->name) + strlen(encode_buf) + 8;
|
llen = strlen(hp->name) + strlen(encode_buf) + 8;
|
||||||
|
|
||||||
if ((len + llen) > dlen) {
|
if ((len + llen) > dlen) {
|
||||||
char *m = buf;
|
char *m = NULL;
|
||||||
dlen += (blocksize + (len + llen));
|
dlen += (blocksize + (len + llen));
|
||||||
if (!(buf = realloc(buf, dlen))) {
|
if (!(m = realloc(buf, dlen))) {
|
||||||
buf = m;
|
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
buf = m;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch_snprintf(buf + len, dlen - len, "%s: %s\n", hp->name, *encode_buf == '\0' ? "_undef_" : encode_buf);
|
switch_snprintf(buf + len, dlen - len, "%s: %s\n", hp->name, *encode_buf == '\0' ? "_undef_" : encode_buf);
|
||||||
|
@ -1591,12 +1588,12 @@ SWITCH_DECLARE(switch_status_t) switch_event_serialize(switch_event_t *event, ch
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((len + llen) > dlen) {
|
if ((len + llen) > dlen) {
|
||||||
char *m = buf;
|
char *m = NULL;
|
||||||
dlen += (blocksize + (len + llen));
|
dlen += (blocksize + (len + llen));
|
||||||
if (!(buf = realloc(buf, dlen))) {
|
if (!(m = realloc(buf, dlen))) {
|
||||||
buf = m;
|
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
buf = m;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (blen) {
|
if (blen) {
|
||||||
|
@ -2244,6 +2241,7 @@ SWITCH_DECLARE(char *) switch_event_expand_headers_check(switch_event_t *event,
|
||||||
nv = 0;
|
nv = 0;
|
||||||
olen = strlen(in) + 1;
|
olen = strlen(in) + 1;
|
||||||
indup = strdup(in);
|
indup = strdup(in);
|
||||||
|
switch_assert(indup);
|
||||||
endof_indup = end_of_p(indup) + 1;
|
endof_indup = end_of_p(indup) + 1;
|
||||||
|
|
||||||
if ((data = malloc(olen))) {
|
if ((data = malloc(olen))) {
|
||||||
|
@ -2438,12 +2436,10 @@ SWITCH_DECLARE(char *) switch_event_expand_headers_check(switch_event_t *event,
|
||||||
} else {
|
} else {
|
||||||
switch_stream_handle_t stream = { 0 };
|
switch_stream_handle_t stream = { 0 };
|
||||||
char *expanded = NULL;
|
char *expanded = NULL;
|
||||||
|
char *expanded_vname = NULL;
|
||||||
|
|
||||||
SWITCH_STANDARD_STREAM(stream);
|
SWITCH_STANDARD_STREAM(stream);
|
||||||
|
|
||||||
if (stream.data) {
|
|
||||||
char *expanded_vname = NULL;
|
|
||||||
|
|
||||||
if ((expanded_vname = switch_event_expand_headers_check(event, (char *) vname, var_list, api_list, recur+1)) == vname) {
|
if ((expanded_vname = switch_event_expand_headers_check(event, (char *) vname, var_list, api_list, recur+1)) == vname) {
|
||||||
expanded_vname = NULL;
|
expanded_vname = NULL;
|
||||||
} else {
|
} else {
|
||||||
|
@ -2470,13 +2466,6 @@ SWITCH_DECLARE(char *) switch_event_expand_headers_check(switch_event_t *event,
|
||||||
|
|
||||||
switch_safe_free(expanded);
|
switch_safe_free(expanded);
|
||||||
switch_safe_free(expanded_vname);
|
switch_safe_free(expanded_vname);
|
||||||
|
|
||||||
} else {
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
|
|
||||||
free(data);
|
|
||||||
free(indup);
|
|
||||||
return (char *) in;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if ((nlen = sub_val ? strlen(sub_val) : 0)) {
|
if ((nlen = sub_val ? strlen(sub_val) : 0)) {
|
||||||
if (len + nlen >= olen) {
|
if (len + nlen >= olen) {
|
||||||
|
@ -2925,6 +2914,7 @@ static void ecd_deliver(event_channel_data_t **ecdP)
|
||||||
|
|
||||||
if ((p = strchr(ecd->event_channel, '.'))) {
|
if ((p = strchr(ecd->event_channel, '.'))) {
|
||||||
char *main_channel = strdup(ecd->event_channel);
|
char *main_channel = strdup(ecd->event_channel);
|
||||||
|
switch_assert(main_channel);
|
||||||
p = strchr(main_channel, '.');
|
p = strchr(main_channel, '.');
|
||||||
*p = '\0';
|
*p = '\0';
|
||||||
_switch_event_channel_broadcast(main_channel, ecd->event_channel, ecd->json, ecd->key, ecd->id);
|
_switch_event_channel_broadcast(main_channel, ecd->event_channel, ecd->json, ecd->key, ecd->id);
|
||||||
|
@ -3022,7 +3012,7 @@ SWITCH_DECLARE(switch_status_t) switch_event_channel_broadcast(const char *event
|
||||||
switch_thread_pool_launch_thread(&td);
|
switch_thread_pool_launch_thread(&td);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((status = switch_queue_trypush(EVENT_CHANNEL_DISPATCH_QUEUE, ecd) != SWITCH_STATUS_SUCCESS)) {
|
if ((status = switch_queue_trypush(EVENT_CHANNEL_DISPATCH_QUEUE, ecd)) != SWITCH_STATUS_SUCCESS) {
|
||||||
cJSON_Delete(ecd->json);
|
cJSON_Delete(ecd->json);
|
||||||
ecd->json = NULL;
|
ecd->json = NULL;
|
||||||
destroy_ecd(&ecd);
|
destroy_ecd(&ecd);
|
||||||
|
|
Loading…
Reference in New Issue