Replace catalog object only if root object does not exist.
Signed-off-by: yzrh <yzrh@noema.org>
This commit is contained in:
parent
56ffe14d5a
commit
a7ecc15614
2 changed files with 14 additions and 8 deletions
|
@ -375,9 +375,11 @@ cnki_pdf(cnki_t **param)
|
|||
printf("Root object is %d.\n", root);
|
||||
}
|
||||
|
||||
int root_gen;
|
||||
|
||||
pdf_object_t *tmp;
|
||||
|
||||
if (pdf_get_obj(&pdf, root, &tmp) != 0) {
|
||||
if ((root_gen = pdf_get_obj(&pdf, root, &tmp)) != 0) {
|
||||
if ((*param)->stat > 0)
|
||||
printf("Root object is missing\n");
|
||||
|
||||
|
@ -442,6 +444,7 @@ cnki_pdf(cnki_t **param)
|
|||
if ((*param)->stat > 0)
|
||||
printf("Catalog object is %d.\n", catalog);
|
||||
|
||||
if (root_gen != 0) {
|
||||
if ((*param)->stat > 1)
|
||||
printf("Replacing catalog object\n");
|
||||
|
||||
|
@ -449,6 +452,7 @@ cnki_pdf(cnki_t **param)
|
|||
|
||||
if ((*param)->stat > 0)
|
||||
printf("Replaced catalog object\n");
|
||||
}
|
||||
} else {
|
||||
if ((*param)->stat > 0)
|
||||
printf("Catalog object is missing\n");
|
||||
|
|
|
@ -232,7 +232,8 @@ pdf_load(pdf_object_t **pdf, FILE **fp, int size_buf)
|
|||
* A dictionary object may have nested dictionary,
|
||||
* but it should not be in a stream
|
||||
*/
|
||||
while ((tmp = _memmem_whitespace(tail + 3,
|
||||
while (ptr->size - (tail - buf) > 3 &&
|
||||
(tmp = _memmem_whitespace(tail + 3,
|
||||
ptr->size - (tail - buf) - 3,
|
||||
">>", 2)) != NULL &&
|
||||
memmem(tail + 3,
|
||||
|
@ -241,7 +242,8 @@ pdf_load(pdf_object_t **pdf, FILE **fp, int size_buf)
|
|||
tail = tmp;
|
||||
|
||||
/* Hack needed for invalid object */
|
||||
while ((tmp = memmem(tail + 2,
|
||||
while (ptr->size - (tail - buf) > 2 &&
|
||||
(tmp = memmem(tail + 2,
|
||||
ptr->size - (tail - buf) - 2,
|
||||
">>", 2)) != NULL &&
|
||||
memmem(tail + 2,
|
||||
|
|
Loading…
Reference in a new issue