Commit a2082728 authored by Josh Coalson's avatar Josh Coalson
Browse files

check for OOM after ogg_sync_buffer()

parent 8d06d47f
...@@ -478,11 +478,16 @@ FLAC__StreamDecoderReadStatus read_callback_(const FLAC__StreamDecoder *unused, ...@@ -478,11 +478,16 @@ FLAC__StreamDecoderReadStatus read_callback_(const FLAC__StreamDecoder *unused,
ogg_bytes_to_read = min(*bytes, OGG_BYTES_CHUNK); ogg_bytes_to_read = min(*bytes, OGG_BYTES_CHUNK);
oggbuf = ogg_sync_buffer(&decoder->private_->ogg.sync_state, ogg_bytes_to_read); 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) { if(0 == oggbuf) {
decoder->protected_->state = OggFLAC__STREAM_DECODER_READ_ERROR; decoder->protected_->state = OggFLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
return FLAC__STREAM_DECODER_READ_STATUS_ABORT; return FLAC__STREAM_DECODER_READ_STATUS_ABORT;
} }
ogg_bytes_read = ogg_bytes_to_read; 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) { if(ogg_sync_wrote(&decoder->private_->ogg.sync_state, ogg_bytes_read) < 0) {
decoder->protected_->state = OggFLAC__STREAM_DECODER_READ_ERROR; decoder->protected_->state = OggFLAC__STREAM_DECODER_READ_ERROR;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment