From e71087631ea69d4785be8da4a962d540bd25bcab Mon Sep 17 00:00:00 2001 From: Tilman Sauerbeck Date: Thu, 17 Aug 2006 19:27:43 +0200 Subject: [PATCH] Check the EOF flag on zero reads. --- ext/vcedit.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ext/vcedit.c b/ext/vcedit.c index 795b0c3..70eae05 100644 --- a/ext/vcedit.c +++ b/ext/vcedit.c @@ -240,7 +240,7 @@ _fetch_next_packet (vcedit_state *s, ogg_packet *p, ogg_page *page) bytes = fread (buffer, 1, CHUNKSIZE, s->in); ogg_sync_wrote (&s->oy, bytes); - if (!bytes) + if (!bytes && feof (s->in)) return 0; } @@ -355,7 +355,7 @@ vcedit_open (vcedit_state *state) buffer = ogg_sync_buffer (&state->oy, CHUNKSIZE); bytes = fread (buffer, 1, CHUNKSIZE, state->in); - if (!bytes && i < 2) { + if (!bytes && feof (state->in) && i < 2) { ret = VCEDIT_ERR_INVAL; goto err; } @@ -536,8 +536,7 @@ vcedit_write (vcedit_state *state) bytes = fread (buffer, 1, CHUNKSIZE, state->in); ogg_sync_wrote (&state->oy, bytes); - if (!bytes) - state->eosin = 1; + state->eosin = !bytes && feof (state->in); } fclose (out); -- 2.30.2