diff options
author | José Aliste <jaliste@src.gnome.org> | 2013-11-18 22:52:08 +0100 |
---|---|---|
committer | Albert Astals Cid <aacid@kde.org> | 2013-11-18 22:52:08 +0100 |
commit | 47605a8aaf85bee21601219b04c0c8e6cf982507 (patch) | |
tree | 0bab734b409f642e02908fd9dc43618270f5dc57 | |
parent | 491f0a170c72271a7a9ce049fbcfe81f08cff162 (diff) |
Catalog: sort entries of NameTrees to make sure lookup works
Bug #26049
-rw-r--r-- | poppler/Catalog.cc | 12 | ||||
-rw-r--r-- | poppler/Catalog.h | 2 |
2 files changed, 14 insertions, 0 deletions
diff --git a/poppler/Catalog.cc b/poppler/Catalog.cc index 6bd511a1..f17f2c0c 100644 --- a/poppler/Catalog.cc +++ b/poppler/Catalog.cc @@ -27,6 +27,7 @@ // Copyright (C) 2012 Fabio D'Urso <fabiodurso@hotmail.it> // Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de> // Copyright (C) 2013 Julien Nabet <serval2412@yahoo.fr> +// Copyright (C) 2013 José Aliste <jaliste@src.gnome.org> // // To see a description of the changes please see the Changelog file that // came with your tarball or type make ChangeLog if you are building from git @@ -657,9 +658,20 @@ void NameTree::addEntry(Entry *entry) ++length; } +int NameTree::Entry::cmpEntry(const void *voidEntry, const void *voidOtherEntry) +{ + Entry *entry = *(NameTree::Entry **) voidEntry; + Entry *otherEntry = *(NameTree::Entry **) voidOtherEntry; + + return entry->name.cmp(&otherEntry->name); +} + void NameTree::init(XRef *xrefA, Object *tree) { xref = xrefA; parse(tree); + if (entries && length > 0) { + qsort(entries, length, sizeof(Entry *), Entry::cmpEntry); + } } void NameTree::parse(Object *tree) { diff --git a/poppler/Catalog.h b/poppler/Catalog.h index 24a3dcfb..384f6342 100644 --- a/poppler/Catalog.h +++ b/poppler/Catalog.h @@ -22,6 +22,7 @@ // Copyright (C) 2010 Hib Eris <hib@hiberis.nl> // Copyright (C) 2012 Fabio D'Urso <fabiodurso@hotmail.it> // Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de> +// Copyright (C) 2013 José Aliste <jaliste@src.gnome.org> // // To see a description of the changes please see the Changelog file that // came with your tarball or type make ChangeLog if you are building from git @@ -76,6 +77,7 @@ private: GooString name; Object value; void free(); + static int cmpEntry(const void *voidEntry, const void *voidOtherEntry); static int cmp(const void *key, const void *entry); }; |