From 01cecf328ade6b10c40102ddcb2328c00e6d570b Mon Sep 17 00:00:00 2001
From: Pompolic <pompolic@special-circumstanc.es>
Date: Thu, 20 Feb 2020 20:39:13 +0100
Subject: [PATCH] Fix bug causing insufficient number of bytes allocated for
 array

---
 pdf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/pdf.c b/pdf.c
index 363c08b..f09e564 100644
--- a/pdf.c
+++ b/pdf.c
@@ -410,11 +410,11 @@ act_a85string(const HParseResult *p, void *u)
 	 * The latter two happening if the group was parsed from a partial
 	 * group consisting less than 5 chars */
 	HBytes *last_chunk = seq->elements[seq->used-1];
-	required_bytes = chunk_number * 4 + last_chunk->len;
+	required_bytes = (chunk_number * 4 + last_chunk->len) * 8;
 
 	result_bytes = h_arena_malloc(p->arena, required_bytes);
 
-	/* Memcpy all but the group's bytes into a single array */
+	/* memcpy all but the last group's bytes into a single array */
 	for (size_t i = 0; i < seq->used-1; ++i)
 	{
 		HBytes *chunk = H_CAST_BYTES(seq->elements[i]);
-- 
GitLab