From 09e86060bf0aabee5a4b28770b673a743beec0dd Mon Sep 17 00:00:00 2001 From: "Sven M. Hallberg" <pesco@khjk.org> Date: Sat, 8 Feb 2020 16:41:56 +0100 Subject: [PATCH] remove some warnings when compiling with -Wsign-compare --- pdf.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pdf.c b/pdf.c index 2e5e321..2504e78 100644 --- a/pdf.c +++ b/pdf.c @@ -1248,11 +1248,11 @@ p_xrefdata__m(HAllocator *mm__, const Dict *dict) return p_fail; if (i < 3) { /* we can't take >64 bits and want to use size_t */ - if (w > 8 || w > sizeof(size_t)) + if (w > 8 || (uint64_t)w > sizeof(size_t)) return p_fail; W[i] = (size_t)w; } else { - if (w > SIZE_MAX - Wskip) + if ((uint64_t)w > SIZE_MAX - Wskip) return p_fail; /* overflow */ Wskip += w; } @@ -1330,7 +1330,7 @@ p_xrefdata__m(HAllocator *mm__, const Dict *dict) if (base->token_type != TT_SINT || base->sint < 0 || n->token_type != TT_SINT || n->sint < 0 || - n->sint > SIZE_MAX) + (uint64_t)n->sint > SIZE_MAX) return p_fail; p_subs[i] = p_xrefsub__m(mm__, base->sint, n->sint, @@ -1467,7 +1467,7 @@ parse_xrefs(const uint8_t *input, size_t sz, size_t *nxrefs) * one xref section at the beginning of the file that is * allowed to point forward. */ - if (tok->sint >= offset) + if ((uint64_t)tok->sint >= offset) nfwd++; if (nfwd > 1) { fprintf(stderr, "%s: /Prev pointer of xref section at " -- GitLab