From: Josh Coalson Date: Tue, 23 Sep 2003 20:29:49 +0000 (+0000) Subject: check for OOM after ogg_sync_buffer() X-Git-Tag: 1.2.0~1035 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a2082728335788e60a0ed30e4d2344c2a87bd983;p=platform%2Fupstream%2Fflac.git check for OOM after ogg_sync_buffer() --- diff --git a/src/libOggFLAC/stream_decoder.c b/src/libOggFLAC/stream_decoder.c index 849df860..66f2bdf1 100644 --- a/src/libOggFLAC/stream_decoder.c +++ b/src/libOggFLAC/stream_decoder.c @@ -478,11 +478,16 @@ FLAC__StreamDecoderReadStatus read_callback_(const FLAC__StreamDecoder *unused, ogg_bytes_to_read = min(*bytes, OGG_BYTES_CHUNK); oggbuf = ogg_sync_buffer(&decoder->private_->ogg.sync_state, ogg_bytes_to_read); - if(decoder->private_->read_callback(decoder, (FLAC__byte*)oggbuf, &ogg_bytes_to_read, decoder->private_->client_data) != FLAC__STREAM_DECODER_READ_STATUS_CONTINUE) { - decoder->protected_->state = OggFLAC__STREAM_DECODER_READ_ERROR; + if(0 == oggbuf) { + decoder->protected_->state = OggFLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; return FLAC__STREAM_DECODER_READ_STATUS_ABORT; } + ogg_bytes_read = ogg_bytes_to_read; + if(decoder->private_->read_callback(decoder, (FLAC__byte*)oggbuf, &ogg_bytes_read, decoder->private_->client_data) != FLAC__STREAM_DECODER_READ_STATUS_CONTINUE) { + decoder->protected_->state = OggFLAC__STREAM_DECODER_READ_ERROR; + return FLAC__STREAM_DECODER_READ_STATUS_ABORT; + } if(ogg_sync_wrote(&decoder->private_->ogg.sync_state, ogg_bytes_read) < 0) { decoder->protected_->state = OggFLAC__STREAM_DECODER_READ_ERROR;