From 280477b42acc1fe606d3c56e9e609c179dbbcf9a Mon Sep 17 00:00:00 2001 From: hrdl-github <7808331-hrdl@users.noreply.gitlab.com> Date: Tue, 14 Nov 2023 12:46:05 +0100 Subject: [PATCH] Bug 707317: fix string comparison of non-utf8 strings --- source/pdf/pdf-object.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/source/pdf/pdf-object.c b/source/pdf/pdf-object.c index 10f7d6d76e..a8b252c9fd 100644 --- a/source/pdf/pdf-object.c +++ b/source/pdf/pdf-object.c @@ -590,19 +590,12 @@ do_objcmp(fz_context *ctx, pdf_obj *a, pdf_obj *b, int check_streams) return 0; case PDF_STRING: - if (STRING(a)->len < STRING(b)->len) - { - if (memcmp(STRING(a)->buf, STRING(b)->buf, STRING(a)->len) <= 0) - return -1; - return 1; - } - if (STRING(a)->len > STRING(b)->len) - { - if (memcmp(STRING(a)->buf, STRING(b)->buf, STRING(b)->len) >= 0) - return 1; + i = strcmp(pdf_to_text_string(ctx, a), pdf_to_text_string(ctx, b)); + if (i < 0) return -1; - } - return memcmp(STRING(a)->buf, STRING(b)->buf, STRING(a)->len); + if (i > 0) + return 1; + return 0 case PDF_NAME: return strcmp(NAME(a)->n, NAME(b)->n);