diff --git a/pdfio-file.c b/pdfio-file.c index 890ea12..b1bf77b 100644 --- a/pdfio-file.c +++ b/pdfio-file.c @@ -1229,7 +1229,7 @@ load_xref(pdfio_file_t *pdf, // I - PDF file if ((index_array = pdfioDictGetArray(trailer.value.dict, "Index")) != NULL) index_count = index_array->num_values; else - index_count = 0; + index_count = 1; if ((w_array = pdfioDictGetArray(trailer.value.dict, "W")) == NULL) { diff --git a/pdfio-stream.c b/pdfio-stream.c index 4bc401a..9b90611 100644 --- a/pdfio-stream.c +++ b/pdfio-stream.c @@ -514,7 +514,7 @@ pdfioStreamPeek(pdfio_stream_t *st, // I - Stream st->bufptr = st->buffer; st->bufend = st->buffer + remaining; - if ((rbytes = stream_read(st, st->bufptr, sizeof(st->buffer) - remaining)) > 0) + if ((rbytes = stream_read(st, st->bufend, sizeof(st->buffer) - remaining)) > 0) { st->bufend += rbytes; remaining += (size_t)rbytes; diff --git a/pdfio-value.c b/pdfio-value.c index f9384fb..f896c3f 100644 --- a/pdfio-value.c +++ b/pdfio-value.c @@ -359,7 +359,18 @@ _pdfioValueRead(pdfio_file_t *pdf, // I - PDF file // Integer or object ref... unsigned char *tempptr; // Pointer into buffer - PDFIO_DEBUG("_pdfioValueRead: %d bytes left in buffer.\n", (int)(tb->bufend - tb->bufptr)); +#ifdef DEBUG + PDFIO_DEBUG("_pdfioValueRead: %d bytes left in buffer: '", (int)(tb->bufend - tb->bufptr)); + for (tempptr = tb->bufptr; tempptr < tb->bufend; tempptr ++) + { + if (*tempptr < ' ' || *tempptr == 0x7f) + PDFIO_DEBUG("\\%03o", *tempptr); + else + PDFIO_DEBUG("%c", *tempptr); + } + PDFIO_DEBUG("'.\n"); +#endif // DEBUG + if ((tb->bufend - tb->bufptr) < 10) { // Fill up buffer... @@ -370,20 +381,18 @@ _pdfioValueRead(pdfio_file_t *pdf, // I - PDF file if ((bytes = (tb->peek_cb)(tb->cb_data, tb->buffer, sizeof(tb->buffer))) > 0) tb->bufend = tb->buffer + bytes; - PDFIO_DEBUG("_pdfioValueRead: %d bytes now left in buffer.\n", (int)(tb->bufend - tb->bufptr)); - } - #ifdef DEBUG - PDFIO_DEBUG("_pdfioValueRead: Bytes are '"); - for (tempptr = tb->bufptr; tempptr < tb->bufend; tempptr ++) - { - if (*tempptr < ' ' || *tempptr == 0x7f) - PDFIO_DEBUG("\\%03o", *tempptr); - else - PDFIO_DEBUG("%c", *tempptr); - } - PDFIO_DEBUG("'.\n"); + PDFIO_DEBUG("_pdfioValueRead: %d bytes now in buffer: '", (int)(tb->bufend - tb->bufptr)); + for (tempptr = tb->bufptr; tempptr < tb->bufend; tempptr ++) + { + if (*tempptr < ' ' || *tempptr == 0x7f) + PDFIO_DEBUG("\\%03o", *tempptr); + else + PDFIO_DEBUG("%c", *tempptr); + } + PDFIO_DEBUG("'.\n"); #endif // DEBUG + } tempptr = tb->bufptr;