Don't try to pre-load object streams since that interferes with reading the

rest of an xref stream...
This commit is contained in:
Michael R Sweet 2021-08-24 14:07:34 -04:00
parent 6745f785b7
commit 6d42b6834e
No known key found for this signature in database
GPG Key ID: BE67C75EC81F3244

View File

@ -992,9 +992,11 @@ load_obj_stream(pdfio_obj_t *obj) // I - Object to load
char buffer[32]; // Token char buffer[32]; // Token
size_t cur_obj, // Current object size_t cur_obj, // Current object
num_objs = 0; // Number of objects num_objs = 0; // Number of objects
pdfio_obj_t *objs[1000]; // Objects pdfio_obj_t *objs[16384]; // Objects
PDFIO_DEBUG("load_obj_stream(obj=%p(%d))\n", obj, (int)obj->number);
// Open the object stream... // Open the object stream...
if ((st = pdfioObjOpenStream(obj, true)) == NULL) if ((st = pdfioObjOpenStream(obj, true)) == NULL)
{ {
@ -1170,7 +1172,7 @@ load_xref(pdfio_file_t *pdf, // I - PDF file
pdfio_stream_t *st; // Stream pdfio_stream_t *st; // Stream
unsigned char buffer[32]; // Read buffer unsigned char buffer[32]; // Read buffer
size_t num_sobjs = 0, // Number of object streams size_t num_sobjs = 0, // Number of object streams
sobjs[1000]; // Object streams to load sobjs[4096]; // Object streams to load
if ((number = strtoimax(line, &ptr, 10)) < 1) if ((number = strtoimax(line, &ptr, 10)) < 1)
{ {
@ -1300,16 +1302,8 @@ load_xref(pdfio_file_t *pdf, // I - PDF file
if (w[0] > 0 && buffer[0] == 2) if (w[0] > 0 && buffer[0] == 2)
{ {
// Object streams need to be loaded into memory... // Object streams need to be loaded into memory, so add them
if ((obj = pdfioFileFindObj(pdf, (size_t)offset)) != NULL) // to the list of objects to load later as needed...
{
// Load it now...
if (!load_obj_stream(obj))
return (false);
}
else
{
// Add it to the list of objects to load later...
for (i = 0; i < num_sobjs; i ++) for (i = 0; i < num_sobjs; i ++)
{ {
if (sobjs[i] == (size_t)offset) if (sobjs[i] == (size_t)offset)
@ -1319,7 +1313,6 @@ load_xref(pdfio_file_t *pdf, // I - PDF file
if (i >= num_sobjs && num_sobjs < (sizeof(sobjs) / sizeof(sobjs[0]))) if (i >= num_sobjs && num_sobjs < (sizeof(sobjs) / sizeof(sobjs[0])))
sobjs[num_sobjs ++] = (size_t)offset; sobjs[num_sobjs ++] = (size_t)offset;
} }
}
else if (!add_obj(pdf, (size_t)number, (unsigned short)generation, offset)) else if (!add_obj(pdf, (size_t)number, (unsigned short)generation, offset))
return (false); return (false);