vorbiscomment: Fix handling very short files.

When setting up a new chain link, vcedit_open_callbacks
always tries to read a new chunk at the edit of the
stream identification loop. This could fail if the
whole segment fits within a single, already buffered
chunk.

Instead, check for a new available page before trying
to buffer more data. As long as there's a data page
available after the header pages, this will succeed,
exiting early without trying to load data unnecessarily.

Thanks to lsd for reporting the issue.
Signed-off-by: default avatarThomas Daede <tdaede@mozilla.com>
parent 3d014b19
...@@ -570,6 +570,9 @@ int vcedit_open_callbacks(vcedit_state *state, void *in, ...@@ -570,6 +570,9 @@ int vcedit_open_callbacks(vcedit_state *state, void *in,
} }
while(1) while(1)
{ {
if(ogg_sync_pageout(state->oy, &og) == 1)
break;
buffer = ogg_sync_buffer(state->oy, CHUNKSIZE); buffer = ogg_sync_buffer(state->oy, CHUNKSIZE);
bytes = state->read(buffer, 1, CHUNKSIZE, state->in); bytes = state->read(buffer, 1, CHUNKSIZE, state->in);
...@@ -581,9 +584,6 @@ int vcedit_open_callbacks(vcedit_state *state, void *in, ...@@ -581,9 +584,6 @@ int vcedit_open_callbacks(vcedit_state *state, void *in,
} }
ogg_sync_wrote(state->oy, bytes); ogg_sync_wrote(state->oy, bytes);
if(ogg_sync_pageout(state->oy, &og) == 1)
break;
} }
if(!ogg_page_bos(&og)) { if(!ogg_page_bos(&og)) {
read_bos = 0; read_bos = 0;
......
Markdown is supported
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