diff options
author | Tor Andersson <tor@ghostscript.com> | 2009-08-17 13:32:38 +0200 |
---|---|---|
committer | Tor Andersson <tor@ghostscript.com> | 2009-08-17 13:32:38 +0200 |
commit | 1d2eb9d542b11e488dbd206c6ef9936b4f60fc13 (patch) | |
tree | 99bffbb65aff57e214c125d581ccc71a3fedbbfe | |
parent | bca0a5b5a0a36fa80a1ba4fe2e6e43656b302a2e (diff) | |
download | mupdf-1d2eb9d542b11e488dbd206c6ef9936b4f60fc13.tar.xz |
Fix string comparisons in fz_objcmp to allow for embedded zeroes and sort properly.
-rw-r--r-- | fitz/obj_simple.c | 12 |
1 files 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: |