diff options
author | Alexey Yakovenko <wakeroid@gmail.com> | 2009-09-27 14:32:52 +0200 |
---|---|---|
committer | Alexey Yakovenko <wakeroid@gmail.com> | 2009-09-27 14:32:52 +0200 |
commit | b0b2e62bca484920576f831957ad88a74afd262a (patch) | |
tree | 737d310cfce39ef335ff1a0d0e509217bfef922a /streamer.c | |
parent | 4e876eb8d3074bfe4ba273df5f4e88c3dbc45b1d (diff) |
fixed buffer overflow bug in streamer
Diffstat (limited to 'streamer.c')
-rw-r--r-- | streamer.c | 11 |
1 files changed, 5 insertions, 6 deletions
@@ -471,12 +471,11 @@ apply_replay_gain_float32 (playItem_t *it, char *bytes, int size) { } static void -mono_int16_to_stereo_int16 (int16_t *in, uint16_t *out, int nsamples) { +mono_int16_to_stereo_int16 (int16_t *in, int16_t *out, int nsamples) { while (nsamples > 0) { - int16_t sample = *in; + int16_t sample = *in++; *out++ = sample; *out++ = sample; - in++; nsamples--; } } @@ -541,15 +540,15 @@ streamer_read_async (char *bytes, int size) { int i; if (decoder->info.channels == 2) { bytesread = decoder->read_int16 (bytes, size); - codec_unlock (); apply_replay_gain_int16 (&str_streaming_song, bytes, size); + codec_unlock (); } else { bytesread = decoder->read_int16 (g_readbuffer, size>>1); - codec_unlock (); apply_replay_gain_int16 (&str_streaming_song, g_readbuffer, size>>1); - mono_int16_to_stereo_int16 ((int16_t*)g_readbuffer, (int16_t*)bytes, size>>1); + mono_int16_to_stereo_int16 ((int16_t*)g_readbuffer, (int16_t*)bytes, size>>2); bytesread *= 2; + codec_unlock (); } } else if (src_is_valid_ratio ((double)p_get_rate ()/samplerate)) { |