diff --git a/vorbiscomment/vcedit.c b/vorbiscomment/vcedit.c index e8ff1f5483f0fa06e5eb98487aa5c6fa6821c3c4..3aec292f801474ba70f10eebcf8999db66cbc21f 100644 --- a/vorbiscomment/vcedit.c +++ b/vorbiscomment/vcedit.c @@ -6,7 +6,7 @@ * * Comment editing backend, suitable for use by nice frontend interfaces. * - * last modified: $Id: vcedit.c,v 1.21 2002/09/12 12:41:52 msmith Exp $ + * last modified: $Id: vcedit.c,v 1.22 2002/09/12 12:48:27 msmith Exp $ */ #include @@ -199,6 +199,7 @@ int vcedit_open_callbacks(vcedit_state *state, void *in, char *buffer; int bytes,i; + int chunks = 0; ogg_packet *header; ogg_packet header_main; ogg_packet header_comments; @@ -212,19 +213,25 @@ int vcedit_open_callbacks(vcedit_state *state, void *in, state->oy = malloc(sizeof(ogg_sync_state)); ogg_sync_init(state->oy); - buffer = ogg_sync_buffer(state->oy, CHUNKSIZE); - bytes = state->read(buffer, 1, CHUNKSIZE, state->in); + while(1) + { + buffer = ogg_sync_buffer(state->oy, CHUNKSIZE); + bytes = state->read(buffer, 1, CHUNKSIZE, state->in); - ogg_sync_wrote(state->oy, bytes); + ogg_sync_wrote(state->oy, bytes); - if(ogg_sync_pageout(state->oy, &og) != 1) - { - if(byteslasterror = _("Input truncated or empty."); - else - state->lasterror = _("Input is not an Ogg bitstream."); - goto err; - } + if(ogg_sync_pageout(state->oy, &og) == 1) + break; + + if(chunks++ >= 10) /* Bail if we don't find data in the first 40 kB */ + { + if(byteslasterror = _("Input truncated or empty."); + else + state->lasterror = _("Input is not an Ogg bitstream."); + goto err; + } + } state->serial = ogg_page_serialno(&og);