]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Handle zero channels when allocating for resampler
authorTravis Cross <tc@traviscross.com>
Fri, 22 Aug 2014 01:59:11 +0000 (01:59 +0000)
committerTravis Cross <tc@traviscross.com>
Fri, 22 Aug 2014 01:59:11 +0000 (01:59 +0000)
When the number of channels was zero, we were calling malloc with a
size of zero.  While defined, this is unusual.  And since we're
initializing the speex resampler as though there were one channel in
this case, we should probably just allocate the space for it.

src/switch_resample.c

index fa229a68cf5a512c6e0b6ab3c213cc58430b1bce..ed584e39af57ba886d0bbf026ea6f788f57961d6 100644 (file)
@@ -78,7 +78,7 @@ SWITCH_DECLARE(switch_status_t) switch_resample_perform_create(switch_audio_resa
        resampler->factor = (lto_rate / lfrom_rate);
        resampler->rfactor = (lfrom_rate / lto_rate);
        resampler->to_size = resample_buffer(to_rate, from_rate, (uint32_t) to_size);
-       resampler->to = malloc(resampler->to_size * sizeof(int16_t) * channels);
+       resampler->to = malloc(resampler->to_size * sizeof(int16_t) * (channels ? channels : 1));
        resampler->channels = channels;
 
        return SWITCH_STATUS_SUCCESS;