FS-8711 #resolve [fix a couple of possible memory leaks in mod_skinny packet reading code]

This commit is contained in:
nneul on mst.edu 2016-01-06 10:54:47 -06:00
parent 70b8c17763
commit 60f514362d
2 changed files with 6 additions and 1 deletions

View File

@ -1910,6 +1910,7 @@ static void *SWITCH_THREAD_FUNC listener_run(switch_thread_t *thread, void *obj)
add_listener(listener); add_listener(listener);
while (listener_is_ready(listener)) { while (listener_is_ready(listener)) {
switch_safe_free(request);
status = skinny_read_packet(listener, &request); status = skinny_read_packet(listener, &request);
if (status != SWITCH_STATUS_SUCCESS) { if (status != SWITCH_STATUS_SUCCESS) {
@ -1932,10 +1933,12 @@ static void *SWITCH_THREAD_FUNC listener_run(switch_thread_t *thread, void *obj)
default: default:
skinny_log_l_msg(listener, SWITCH_LOG_DEBUG, "Communication Error\n"); skinny_log_l_msg(listener, SWITCH_LOG_DEBUG, "Communication Error\n");
} }
switch_safe_free(request);
switch_clear_flag_locked(listener, LFLAG_RUNNING); switch_clear_flag_locked(listener, LFLAG_RUNNING);
break; break;
} }
if (!listener_is_ready(listener)) { if (!listener_is_ready(listener)) {
switch_safe_free(request);
break; break;
} }
@ -1944,13 +1947,14 @@ static void *SWITCH_THREAD_FUNC listener_run(switch_thread_t *thread, void *obj)
} }
if (skinny_handle_request(listener, request) != SWITCH_STATUS_SUCCESS) { if (skinny_handle_request(listener, request) != SWITCH_STATUS_SUCCESS) {
switch_clear_flag_locked(listener, LFLAG_RUNNING);
switch_safe_free(request); switch_safe_free(request);
switch_clear_flag_locked(listener, LFLAG_RUNNING);
break; break;
} else { } else {
switch_safe_free(request); switch_safe_free(request);
} }
} }
switch_safe_free(request);
remove_listener(listener); remove_listener(listener);

View File

@ -141,6 +141,7 @@ switch_status_t skinny_read_packet(listener_t *listener, skinny_message_t **req)
} }
if (!listener_is_ready(listener)) { if (!listener_is_ready(listener)) {
switch_safe_free(request);
break; break;
} }
if (!switch_status_is_timeup(status) && !SWITCH_STATUS_IS_BREAK(status) && (status != SWITCH_STATUS_SUCCESS)) { if (!switch_status_is_timeup(status) && !SWITCH_STATUS_IS_BREAK(status) && (status != SWITCH_STATUS_SUCCESS)) {