Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Xiph.Org
flac
Commits
e8e0ae75
Commit
e8e0ae75
authored
Feb 20, 2003
by
Josh Coalson
Browse files
fix bug where seeking past the end of the stream could cause an infinite loop
parent
67479818
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/libFLAC/seekable_stream_decoder.c
View file @
e8e0ae75
...
...
@@ -644,7 +644,7 @@ FLAC_API FLAC__bool FLAC__seekable_stream_decoder_seek_absolute(FLAC__SeekableSt
FLAC__uint64
length
;
FLAC__ASSERT
(
0
!=
decoder
);
FLAC__ASSERT
(
decoder
->
protected_
->
state
==
FLAC__SEEKABLE_STREAM_DECODER_OK
||
decoder
->
protected_
->
state
==
FLAC__SEEKABLE_STREAM_DECODER_END_OF_STREAM
);
FLAC__ASSERT
(
decoder
->
protected_
->
state
==
FLAC__SEEKABLE_STREAM_DECODER_OK
/*@@@@@ why shouldn't you be able to do this?
|| decoder->protected_->state == FLAC__SEEKABLE_STREAM_DECODER_END_OF_STREAM
*/
);
decoder
->
protected_
->
state
=
FLAC__SEEKABLE_STREAM_DECODER_SEEKING
;
...
...
@@ -669,7 +669,7 @@ FLAC_API FLAC__bool FLAC__seekable_stream_decoder_seek_absolute(FLAC__SeekableSt
decoder
->
protected_
->
state
=
FLAC__SEEKABLE_STREAM_DECODER_STREAM_DECODER_ERROR
;
return
false
;
}
if
(
decoder
->
private_
->
stream_info
.
total_samples
>
0
&&
sample
>
decoder
->
private_
->
stream_info
.
total_samples
)
{
if
(
decoder
->
private_
->
stream_info
.
total_samples
>
0
&&
sample
>
=
decoder
->
private_
->
stream_info
.
total_samples
)
{
decoder
->
protected_
->
state
=
FLAC__SEEKABLE_STREAM_DECODER_SEEK_ERROR
;
return
false
;
}
...
...
@@ -982,8 +982,8 @@ FLAC__bool seek_to_absolute_sample_(FLAC__SeekableStreamDecoder *decoder, FLAC__
else
{
/* we need to narrow the search */
FLAC__uint64
this_frame_sample
=
decoder
->
private_
->
last_frame
.
header
.
number
.
sample_number
;
FLAC__ASSERT
(
decoder
->
private_
->
last_frame
.
header
.
number_type
==
FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER
);
if
(
this_frame_sample
==
last_frame_sample
)
{
/* our last move backwards wasn't big enough */
if
(
this_frame_sample
==
last_frame_sample
&&
pos
<
last_pos
)
{
/* our last move backwards wasn't big enough
, double it
*/
pos
-=
(
last_pos
-
pos
);
needs_seek
=
true
;
}
...
...
@@ -1004,6 +1004,14 @@ FLAC__bool seek_to_absolute_sample_(FLAC__SeekableStreamDecoder *decoder, FLAC__
pos
=
(
FLAC__int32
)
upos
;
pos
-=
FLAC__stream_decoder_get_input_bytes_unconsumed
(
decoder
->
private_
->
stream_decoder
);
needs_seek
=
false
;
/*
* if we haven't hit the target frame yet and our position hasn't changed,
* it means we're at the end of the stream and the seek target does not exist.
*/
if
(
last_pos
==
pos
)
{
decoder
->
protected_
->
state
=
FLAC__SEEKABLE_STREAM_DECODER_SEEK_ERROR
;
return
false
;
}
}
}
if
(
pos
<
(
FLAC__int64
)
lower_bound
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment