aboutsummaryrefslogtreecommitdiffstats
path: root/src/pdf_parser.c
diff options
context:
space:
mode:
authoryzrh <yzrh@noema.org>2023-01-04 17:50:25 +0000
committeryzrh <yzrh@noema.org>2023-01-04 17:50:25 +0000
commita7ecc156141b15cfae8b309697e12deae2740841 (patch)
treec3cc224a165f61f831174c0dda2b389de85dc0b9 /src/pdf_parser.c
parent56ffe14d5a8c10163850d3e682c67a282d9b8abc (diff)
downloadmelon-a7ecc156141b15cfae8b309697e12deae2740841.tar.gz
melon-a7ecc156141b15cfae8b309697e12deae2740841.tar.zst
Replace catalog object only if root object does not exist.
Signed-off-by: yzrh <yzrh@noema.org>
Diffstat (limited to 'src/pdf_parser.c')
-rw-r--r--src/pdf_parser.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/pdf_parser.c b/src/pdf_parser.c
index 70d72d5..6520fd5 100644
--- a/src/pdf_parser.c
+++ b/src/pdf_parser.c
@@ -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,