FS-8950 fix a few memory leaks in mod_skinny

This commit is contained in:
Nathan Neulinger 2016-03-16 10:48:30 -05:00
parent 095e1f7bf2
commit da91717b8e
2 changed files with 26 additions and 5 deletions

View File

@ -320,7 +320,7 @@ void skinny_line_get(listener_t *listener, uint32_t instance, struct line_stat_r
switch_assert(listener->profile);
switch_assert(listener->device_name);
helper.button = switch_core_alloc(listener->pool, sizeof(struct line_stat_res_message));
helper.button = calloc(sizeof(struct line_stat_res_message),1);
if ((sql = switch_mprintf(
"SELECT '%d' AS wanted_position, position, label, value, caller_name "
@ -363,7 +363,7 @@ void skinny_speed_dial_get(listener_t *listener, uint32_t instance, struct speed
switch_assert(listener->profile);
switch_assert(listener->device_name);
helper.button = switch_core_alloc(listener->pool, sizeof(struct speed_dial_stat_res_message));
helper.button = calloc(sizeof(struct speed_dial_stat_res_message),1);
if ((sql = switch_mprintf(
"SELECT '%d' AS wanted_position, position, label, value, settings "
@ -407,7 +407,7 @@ void skinny_service_url_get(listener_t *listener, uint32_t instance, struct serv
switch_assert(listener->profile);
switch_assert(listener->device_name);
helper.button = switch_core_alloc(listener->pool, sizeof(struct service_url_stat_res_message));
helper.button = calloc(sizeof(struct service_url_stat_res_message), 1);
if ((sql = switch_mprintf(
"SELECT '%d' AS wanted_position, position, label, value, settings "
@ -453,7 +453,7 @@ void skinny_feature_get(listener_t *listener, uint32_t instance, struct feature_
switch_assert(listener->profile);
switch_assert(listener->device_name);
helper.button = switch_core_alloc(listener->pool, sizeof(struct feature_stat_res_message));
helper.button = calloc(sizeof(struct feature_stat_res_message), 1);
if ((sql = switch_mprintf(
"SELECT '%d' AS wanted_position, position, label, value, settings "

View File

@ -116,6 +116,9 @@ switch_status_t skinny_create_incoming_session(listener_t *listener, uint32_t *l
if (!button || !button->shortname[0]) {
skinny_log_l(listener, SWITCH_LOG_CRIT, "Line %d not found on device\n", *line_instance_p);
if ( button ) {
switch_safe_free(button);
}
goto error;
}
@ -199,11 +202,17 @@ error:
}
listener->profile->ib_failed_calls++;
if ( button ) {
switch_safe_free(button);
}
return SWITCH_STATUS_FALSE;
done:
*session = nsession;
listener->profile->ib_calls++;
if ( button ) {
switch_safe_free(button);
}
return SWITCH_STATUS_SUCCESS;
}
@ -1524,6 +1533,7 @@ switch_status_t skinny_handle_stimulus_message(listener_t *listener, skinny_mess
return SWITCH_STATUS_FALSE;
}
skinny_session_process_dest(session, listener, line_instance, button_speed_dial->line, '\0', 0);
switch_safe_free(button_speed_dial);
}
break;
case SKINNY_BUTTON_HOLD:
@ -1582,10 +1592,12 @@ switch_status_t skinny_handle_stimulus_message(listener_t *listener, skinny_mess
skinny_create_incoming_session(listener, &line_instance, &session);
if ( ! session ) {
skinny_log_l_msg(listener, SWITCH_LOG_CRIT, "Unable to handle stimulus message, couldn't create incoming session.\n");
switch_safe_free(button_line);
return SWITCH_STATUS_FALSE;
}
skinny_session_process_dest(session, listener, line_instance, NULL, '\0', 0);
}
switch_safe_free(button_line);
break;
default:
@ -1709,6 +1721,8 @@ switch_status_t skinny_handle_speed_dial_stat_request(listener_t *listener, skin
send_speed_dial_stat_res(listener, request->data.speed_dial_req.number, button->line, button->label);
switch_safe_free(button);
return SWITCH_STATUS_SUCCESS;
}
@ -1725,6 +1739,8 @@ switch_status_t skinny_handle_line_stat_request(listener_t *listener, skinny_mes
memcpy(&message->data.line_res, button, sizeof(struct line_stat_res_message));
switch_safe_free(button);
skinny_send_reply(listener, message, SWITCH_TRUE);
return SWITCH_STATUS_SUCCESS;
@ -2407,6 +2423,8 @@ switch_status_t skinny_handle_service_url_stat_request(listener_t *listener, ski
skinny_send_reply(listener, message, SWITCH_TRUE);
switch_safe_free(button);
return SWITCH_STATUS_SUCCESS;
}
@ -2425,6 +2443,8 @@ switch_status_t skinny_handle_feature_stat_request(listener_t *listener, skinny_
skinny_send_reply(listener, message, SWITCH_TRUE);
switch_safe_free(button);
return SWITCH_STATUS_SUCCESS;
}
@ -2568,7 +2588,7 @@ switch_status_t skinny_handle_updatecapabilities(listener_t *listener, skinny_me
}
i = 0;
pos = 0;
codec_string = switch_core_alloc(listener->pool, string_len+1);
codec_string = calloc(string_len+1, 1);
for (string_pos = 0; string_pos < string_len; string_pos++) {
char *codec = codec_order[i];
switch_assert(i < n);
@ -2591,6 +2611,7 @@ switch_status_t skinny_handle_updatecapabilities(listener_t *listener, skinny_me
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
"Codecs %s supported.\n", codec_string);
switch_safe_free(codec_string);
return SWITCH_STATUS_SUCCESS;
}