From fc40e4ab79bd0a575c52cb5d1d7985ef53cdcd51 Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Fri, 2 May 2014 03:38:14 +0000 Subject: [PATCH] Avoid leaking data_buf in mod_conference When we couldn't acquire the rwlock on the conference we were leaking a buffer we just allocated. On a 48k/10ms conference we would leak 960 bytes per attempt. --- src/mod/applications/mod_conference/mod_conference.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/mod/applications/mod_conference/mod_conference.c b/src/mod/applications/mod_conference/mod_conference.c index 87cf7a6d3c..8efff9bd19 100644 --- a/src/mod/applications/mod_conference/mod_conference.c +++ b/src/mod/applications/mod_conference/mod_conference.c @@ -4515,15 +4515,14 @@ static void *SWITCH_THREAD_FUNC conference_record_thread_run(switch_thread_t *th int lead_in = 20; switch_size_t len = 0; - data_buf_len = samples * sizeof(int16_t); - - switch_zmalloc(data_buf, data_buf_len); - if (switch_thread_rwlock_tryrdlock(conference->rwlock) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Read Lock Fail\n"); return NULL; } + data_buf_len = samples * sizeof(int16_t); + switch_zmalloc(data_buf, data_buf_len); + switch_mutex_lock(globals.hash_mutex); globals.threads++; switch_mutex_unlock(globals.hash_mutex);