mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-20 10:26:51 +00:00
Merge pull request #2756 from signalwire/eslcoverity
[fs_cli, libesl] Coverity fixes.
This commit is contained in:
commit
da7300bee0
@ -1521,7 +1521,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
strncpy(internal_profile.host, "127.0.0.1", sizeof(internal_profile.host));
|
||||
strncpy(internal_profile.pass, "ClueCon", sizeof(internal_profile.pass));
|
||||
strncpy(internal_profile.name, hostname, sizeof(internal_profile.name));
|
||||
snprintf(internal_profile.name, sizeof(internal_profile.name), "%s", hostname);
|
||||
internal_profile.port = 8021;
|
||||
set_fn_keys(&internal_profile);
|
||||
esl_set_string(internal_profile.prompt_color, prompt_color);
|
||||
|
@ -1147,11 +1147,6 @@ fail:
|
||||
hooks->deallocate(buffer->buffer);
|
||||
}
|
||||
|
||||
if (printed != NULL)
|
||||
{
|
||||
hooks->deallocate(printed);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -284,9 +284,12 @@ ESL_DECLARE(int) esl_snprintf(char *buffer, size_t count, const char *fmt, ...)
|
||||
|
||||
static void null_logger(const char *file, const char *func, int line, int level, const char *fmt, ...)
|
||||
{
|
||||
if (file && func && line && level && fmt) {
|
||||
return;
|
||||
}
|
||||
(void)file;
|
||||
(void)func;
|
||||
(void)line;
|
||||
(void)level;
|
||||
(void)fmt;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -696,7 +699,10 @@ ESL_DECLARE(esl_status_t) esl_listen(const char *host, esl_port_t port, esl_list
|
||||
}
|
||||
|
||||
|
||||
esl_socket_reuseaddr(server_sock);
|
||||
if (esl_socket_reuseaddr(server_sock) != 0) {
|
||||
status = ESL_FAIL;
|
||||
goto end;
|
||||
}
|
||||
|
||||
memset(&addr, 0, sizeof(addr));
|
||||
addr.sin_family = AF_INET;
|
||||
@ -751,7 +757,10 @@ ESL_DECLARE(esl_status_t) esl_listen_threaded(const char *host, esl_port_t port,
|
||||
return ESL_FAIL;
|
||||
}
|
||||
|
||||
esl_socket_reuseaddr(server_sock);
|
||||
if (esl_socket_reuseaddr(server_sock) != 0) {
|
||||
status = ESL_FAIL;
|
||||
goto end;
|
||||
}
|
||||
|
||||
memset(&addr, 0, sizeof(addr));
|
||||
addr.sin_family = AF_INET;
|
||||
@ -1060,7 +1069,10 @@ ESL_DECLARE(esl_status_t) esl_connect_timeout(esl_handle_t *handle, const char *
|
||||
}
|
||||
}
|
||||
#else
|
||||
fcntl(handle->sock, F_SETFL, fd_flags);
|
||||
if (fcntl(handle->sock, F_SETFL, fd_flags)) {
|
||||
snprintf(handle->err, sizeof(handle->err), "Socket Connection Error");
|
||||
goto fail;
|
||||
}
|
||||
#endif
|
||||
rval = 0;
|
||||
}
|
||||
@ -1155,13 +1167,6 @@ ESL_DECLARE(esl_status_t) esl_disconnect(esl_handle_t *handle)
|
||||
esl_event_safe_destroy(&handle->last_ievent);
|
||||
esl_event_safe_destroy(&handle->info_event);
|
||||
|
||||
if (mutex) {
|
||||
esl_mutex_unlock(mutex);
|
||||
esl_mutex_lock(mutex);
|
||||
esl_mutex_unlock(mutex);
|
||||
esl_mutex_destroy(&mutex);
|
||||
}
|
||||
|
||||
if (handle->packet_buf) {
|
||||
esl_buffer_destroy(&handle->packet_buf);
|
||||
}
|
||||
@ -1169,6 +1174,13 @@ ESL_DECLARE(esl_status_t) esl_disconnect(esl_handle_t *handle)
|
||||
memset(handle, 0, sizeof(*handle));
|
||||
handle->destroyed = 1;
|
||||
|
||||
if (mutex) {
|
||||
esl_mutex_unlock(mutex);
|
||||
esl_mutex_lock(mutex);
|
||||
esl_mutex_unlock(mutex);
|
||||
esl_mutex_destroy(&mutex);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
@ -1217,7 +1229,7 @@ ESL_DECLARE(esl_status_t) esl_recv_event_timed(esl_handle_t *handle, uint32_t ms
|
||||
status = ESL_BREAK;
|
||||
}
|
||||
|
||||
if (handle->mutex) esl_mutex_unlock(handle->mutex);
|
||||
esl_mutex_unlock(handle->mutex);
|
||||
|
||||
return status;
|
||||
|
||||
@ -1299,14 +1311,12 @@ ESL_DECLARE(esl_status_t) esl_recv_event(esl_handle_t *handle, int check_q, esl_
|
||||
*e++ = '\0';
|
||||
while(*e == '\n' || *e == '\r') e++;
|
||||
|
||||
if (hval) {
|
||||
esl_url_decode(hval);
|
||||
esl_log(ESL_LOG_DEBUG, "RECV HEADER [%s] = [%s]\n", hname, hval);
|
||||
if (!strncmp(hval, "ARRAY::", 7)) {
|
||||
esl_event_add_array(revent, hname, hval);
|
||||
} else {
|
||||
esl_event_add_header_string(revent, ESL_STACK_BOTTOM, hname, hval);
|
||||
}
|
||||
esl_url_decode(hval);
|
||||
esl_log(ESL_LOG_DEBUG, "RECV HEADER [%s] = [%s]\n", hname, hval);
|
||||
if (!strncmp(hval, "ARRAY::", 7)) {
|
||||
esl_event_add_array(revent, hname, hval);
|
||||
} else {
|
||||
esl_event_add_header_string(revent, ESL_STACK_BOTTOM, hname, hval);
|
||||
}
|
||||
|
||||
p = e;
|
||||
@ -1521,11 +1531,15 @@ ESL_DECLARE(esl_status_t) esl_send_recv_timed(esl_handle_t *handle, const char *
|
||||
const char *hval;
|
||||
esl_status_t status;
|
||||
|
||||
if (!handle || !handle->connected || handle->sock == ESL_SOCK_INVALID) {
|
||||
return ESL_FAIL;
|
||||
}
|
||||
if (!handle) {
|
||||
return ESL_FAIL;
|
||||
}
|
||||
|
||||
esl_mutex_lock(handle->mutex);
|
||||
if (!handle->connected || handle->sock == ESL_SOCK_INVALID) {
|
||||
esl_mutex_unlock(handle->mutex);
|
||||
return ESL_FAIL;
|
||||
}
|
||||
|
||||
esl_event_safe_destroy(&handle->last_sr_event);
|
||||
|
||||
|
@ -545,7 +545,6 @@ static esl_status_t esl_event_base_add_header(esl_event_t *event, esl_stack_t st
|
||||
header->value = NULL;
|
||||
header->array = m;
|
||||
header->idx++;
|
||||
m = NULL;
|
||||
}
|
||||
|
||||
i = header->idx + 1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user