From: Clarence Date: Wed, 23 Mar 2022 09:00:02 +0000 (+0800) Subject: [core] fix memory leak in switch_core_asr_feed X-Git-Tag: v1.10.8^2~68^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3d283a989d8ee30dbb3c11be1b9c5f0f68163834;p=thirdparty%2Ffreeswitch.git [core] fix memory leak in switch_core_asr_feed --- diff --git a/src/switch_core_asr.c b/src/switch_core_asr.c index dd0df4302e..6b91922a8a 100644 --- a/src/switch_core_asr.c +++ b/src/switch_core_asr.c @@ -233,6 +233,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_asr_close(switch_asr_handle_t *ah, s status = ah->asr_interface->asr_close(ah, flags); switch_set_flag(ah, SWITCH_ASR_FLAG_CLOSED); + switch_safe_free(ah->dbuf); switch_resample_destroy(&ah->resampler); UNPROTECT_INTERFACE(ah->asr_interface); @@ -260,7 +261,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_asr_feed(switch_asr_handle_t *ah, vo switch_resample_process(ah->resampler, data, len / 2); if (ah->resampler->to_len * 2 > orig_len) { - if (!ah->dbuf) { + if (ah->dbuflen < ah->resampler->to_len * 2) { void *mem; ah->dbuflen = ah->resampler->to_len * 2; mem = realloc(ah->dbuf, ah->dbuflen);