From 1d2eb9d542b11e488dbd206c6ef9936b4f60fc13 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Mon, 17 Aug 2009 13:32:38 +0200 Subject: Fix string comparisons in fz_objcmp to allow for embedded zeroes and sort properly. --- fitz/obj_simple.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/fitz/obj_simple.c b/fitz/obj_simple.c index 69283f26..8736f89a 100644 --- a/fitz/obj_simple.c +++ b/fitz/obj_simple.c @@ -280,9 +280,17 @@ fz_objcmp(fz_obj *a, fz_obj *b) case FZ_STRING: if (a->u.s.len < b->u.s.len) - return -1; - if (a->u.s.len > b->u.s.len) + { + if (memcmp(a->u.s.buf, b->u.s.buf, a->u.s.len) <= 0) + return -1; return 1; + } + if (a->u.s.len > b->u.s.len) + { + if (memcmp(a->u.s.buf, b->u.s.buf, b->u.s.len) >= 0) + return 1; + return -1; + } return memcmp(a->u.s.buf, b->u.s.buf, a->u.s.len); case FZ_NAME: -- cgit v1.2.3