From 06ed0943b4ffd56be1323c336f0cb52379ccd6d1 Mon Sep 17 00:00:00 2001 From: "Sven M. Hallberg" <pesco@khjk.org> Date: Thu, 13 Apr 2023 17:31:08 +0000 Subject: [PATCH] fix format specifier for printing HBytes Since HBytes is a length/pointer pair and not a null-terminated string, we must pass the length as an argument to printf. The correct format specifier for that is "%.*s" (string with "precision" = length), not "%*s" (string with minimum field width). --- pdf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pdf.c b/pdf.c index f0eac27..b310178 100644 --- a/pdf.c +++ b/pdf.c @@ -1091,7 +1091,7 @@ validate_dict_(HParseResult *p, void *u) kj = H_INDEX_BYTES(seq->elements[j], 0); if (bytescmp(ki, kj) == 0) { - log_message(7, "duplicate key /%*s in " + log_message(7, "duplicate key /%.*s in " "dictionary\n", (int)ki.len, ki.token); return false; } @@ -4530,7 +4530,7 @@ act_ks_value(const HParseResult *p, void *u) b = v->bytes; if (b.len > INT_MAX) b.len = INT_MAX; - log_message(7, "parse error in stream (type %*s)\n", + log_message(7, "parse error in stream (type %.*s)\n", (int)b.len, b.token); } return H_MAKE(HParseResult, res); -- GitLab