Commit 29699b50 authored by conrad's avatar conrad

check for eof in oggz_read() before further read_sync's


git-svn-id: http://svn.annodex.net/liboggz/trunk@522 8158c8cd-e7e1-0310-9fa4-c5954c97daef
parent 06db3bfb
...@@ -349,10 +349,14 @@ oggz_read (OGGZ * oggz, long n) ...@@ -349,10 +349,14 @@ oggz_read (OGGZ * oggz, long n)
cb_ret = oggz_read_sync (oggz); cb_ret = oggz_read_sync (oggz);
/* If there's nothing to read yet, don't flag an error */ if (cb_ret == OGGZ_READ_EOF) {
if (reader->current_unit == 0 && cb_ret == OGGZ_READ_EOF) cb_ret = 0; /* If there's nothing to read yet, don't return 0 (eof) */
if (reader->current_unit == 0) cb_ret = 0;
else return 0;
}
while (cb_ret != -1 && cb_ret != 1 && bytes_read > 0 && remaining > 0) { while (cb_ret != OGGZ_STOP_ERR && cb_ret != OGGZ_STOP_OK &&
bytes_read > 0 && remaining > 0) {
bytes = MIN (remaining, CHUNKSIZE); bytes = MIN (remaining, CHUNKSIZE);
buffer = ogg_sync_buffer (&reader->ogg_sync, bytes); buffer = ogg_sync_buffer (&reader->ogg_sync, bytes);
if ((bytes_read = (long) oggz_io_read (oggz, buffer, bytes)) == 0) { if ((bytes_read = (long) oggz_io_read (oggz, buffer, bytes)) == 0) {
...@@ -403,8 +407,11 @@ oggz_read_input (OGGZ * oggz, unsigned char * buf, long n) ...@@ -403,8 +407,11 @@ oggz_read_input (OGGZ * oggz, unsigned char * buf, long n)
cb_ret = oggz_read_sync (oggz); cb_ret = oggz_read_sync (oggz);
/* If there's nothing to read yet, don't flag an error */ if (cb_ret == OGGZ_READ_EOF) {
if (reader->current_unit == 0 && cb_ret == OGGZ_READ_EOF) cb_ret = 0; /* If there's nothing to read yet, don't return 0 (eof) */
if (reader->current_unit == 0) cb_ret = 0;
else return 0;
}
while (cb_ret != -1 && cb_ret != 1 && /* !oggz->eos && */ remaining > 0) { while (cb_ret != -1 && cb_ret != 1 && /* !oggz->eos && */ remaining > 0) {
bytes = MIN (remaining, 4096); bytes = MIN (remaining, 4096);
......
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