From: Michael Jerris Date: Fri, 24 Apr 2015 14:47:16 +0000 (-0500) Subject: FS-7465: make sure write buffer is big enough on stereo file handles X-Git-Tag: v1.4.19~6^2~42 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dbc124d45ee5937283a44087a788065b7cafcb15;p=thirdparty%2Ffreeswitch.git FS-7465: make sure write buffer is big enough on stereo file handles --- diff --git a/src/switch_core_file.c b/src/switch_core_file.c index 66e5df1d6e..81fb16ed28 100644 --- a/src/switch_core_file.c +++ b/src/switch_core_file.c @@ -412,14 +412,14 @@ SWITCH_DECLARE(switch_status_t) switch_core_file_write(switch_file_handle_t *fh, switch_resample_process(fh->resampler, data, (uint32_t) * len); if (fh->resampler->to_len > orig_len) { - if (!fh->dbuf) { + if (!fh->dbuf || (fh->dbuflen < fh->resampler->to_len * 2 * fh->channels)) { void *mem; fh->dbuflen = fh->resampler->to_len * 2 * fh->channels; mem = realloc(fh->dbuf, fh->dbuflen); switch_assert(mem); fh->dbuf = mem; } - switch_assert(fh->resampler->to_len * 2 *fh->channels <= fh->dbuflen); + switch_assert(fh->resampler->to_len * 2 * fh->channels <= fh->dbuflen); memcpy(fh->dbuf, fh->resampler->to, fh->resampler->to_len * 2 * fh->channels); data = fh->dbuf; } else {