From feac2335a0c91b32a5d6a4fe2abd4a7788cf06d8 Mon Sep 17 00:00:00 2001 From: Sebastian Rasmussen Date: Mon, 19 Dec 2016 01:14:39 +0100 Subject: Fix typo in dictionary entry sorting. Commit a92f0db5987b408bef0d9b07277c8ff2329e9ce5 introduced a typo causing pdf_sort_dict() to try to sort non-dict objects. Attempting to do this for non-dict objects causes a segmentation fault. For dictionary objects this causes a performance degradation that has not been noticed. pdf_sort_dict() is called in two places: pdf_dict_get_put() and showgrep(). The resson that calling pdf_sort_dict() from pdf_dict_get_put() does not cause a segmentation fault is that pdf_dict_get_put() makes sure that the object is a dictionary before calling pdf_sort_dict(), which will then decide NOT to sort the dict keys. showgrep() on the other hand does not make sure that it is only processing dict objects before calling pdf_sort_dict() which caused a segmentation fault. --- source/pdf/pdf-object.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source') diff --git a/source/pdf/pdf-object.c b/source/pdf/pdf-object.c index 51f6a679..8d2e2ae4 100644 --- a/source/pdf/pdf-object.c +++ b/source/pdf/pdf-object.c @@ -1584,7 +1584,7 @@ void pdf_sort_dict(fz_context *ctx, pdf_obj *obj) { RESOLVE(obj); - if (OBJ_IS_DICT(obj)) + if (!OBJ_IS_DICT(obj)) return; if (!(obj->flags & PDF_FLAGS_SORTED)) { -- cgit v1.2.3