From 2d7ee624e1dc703fb66f6b186888be64c7e97434 Mon Sep 17 00:00:00 2001 From: "guruprasadX, pawse" Date: Tue, 17 Dec 2013 18:41:51 +0530 Subject: Noise and sometimes tombstone crash observed while seeking FLAC content during playback This patch resolves two issues: 1. Segmentation fault while seeking. 2. Noise during seek. The rootcause of both the above issue are same. Issue happens due to memory corruption of FLAC write buffer during seek. Due to this incorrect address we always observe noise during seek and sometimes the memory read causes seg fault whenever the memory access goes beyond the valid range. Change-Id: If76ca4ab614a02f8b324fc51684d5d9cf25073c8 Signed-off-by: guruprasadX, pawse Signed-off-by: Mazhar --- libFLAC/stream_decoder.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libFLAC/stream_decoder.c b/libFLAC/stream_decoder.c index 916fde6..c20cb66 100644 --- a/libFLAC/stream_decoder.c +++ b/libFLAC/stream_decoder.c @@ -205,6 +205,7 @@ typedef struct FLAC__StreamDecoderPrivate { #if FLAC__HAS_OGG FLAC__bool got_a_frame; /* hack needed in Ogg FLAC seek routine to check when process_single() actually writes a frame */ #endif + FLAC__int32 *newbuffer[FLAC__MAX_CHANNELS]; } FLAC__StreamDecoderPrivate; /*********************************************************************** @@ -2935,13 +2936,12 @@ FLAC__StreamDecoderWriteStatus write_audio_frame_to_client_(FLAC__StreamDecoder /* shift out the samples before target_sample */ if(delta > 0) { unsigned channel; - const FLAC__int32 *newbuffer[FLAC__MAX_CHANNELS]; for(channel = 0; channel < frame->header.channels; channel++) - newbuffer[channel] = buffer[channel] + delta; + decoder->private_->newbuffer[channel] = (FLAC__int32 *)buffer[channel] + delta; decoder->private_->last_frame.header.blocksize -= delta; decoder->private_->last_frame.header.number.sample_number += (FLAC__uint64)delta; /* write the relevant samples */ - return decoder->private_->write_callback(decoder, &decoder->private_->last_frame, newbuffer, decoder->private_->client_data); + return decoder->private_->write_callback(decoder, &decoder->private_->last_frame, (const FLAC__int32 * const *)decoder->private_->newbuffer, decoder->private_->client_data); } else { /* write the relevant samples */ -- cgit v1.2.3