stream_decoder: reset has_seek_table before read_metadata_seektable_()

If a seek table has already been read successfully, then the
has_seek_table flag is true.  Now imagine the file comes with another
seek table, which doesn't make sense, but libFLAC accepts it happily.
If reading this second seek table fails (for example allocation
failure), read_metadata_seektable_() returns false, but the
has_seek_table flag is still true.  If the calling application happens
to ignore this failure, and at some point tries to seek, the process
will crash due to NULL pointer dereference.  This would sure be an
application bug that needs to be fixed, but libFLAC's internal state
is inconsistent, so let's fix this up.

Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
This commit is contained in:
Max Kellermann
2016-07-14 10:22:43 +02:00
committed by Erik de Castro Lopo
parent f7491f9741
commit a52177b0d1

View File

@@ -1418,6 +1418,9 @@ FLAC__bool read_metadata_(FLAC__StreamDecoder *decoder)
decoder->private_->metadata_callback(decoder, &decoder->private_->stream_info, decoder->private_->client_data);
}
else if(type == FLAC__METADATA_TYPE_SEEKTABLE) {
/* just in case we already have a seek table, and reading the next one fails: */
decoder->private_->has_seek_table = false;
if(!read_metadata_seektable_(decoder, is_last, length))
return false;