diff options
author | Sebastian Rasmussen <sebras@gmail.com> | 2018-08-05 22:32:58 +0800 |
---|---|---|
committer | Sebastian Rasmussen <sebras@gmail.com> | 2018-08-10 01:15:48 +0800 |
commit | 6ec845bea34b5a7e42ae4685130daeb6cbae6c9e (patch) | |
tree | 76e63d0a43f2c39a1f69b44204130cd26b194bf2 /source/pdf/pdf-cmap.c | |
parent | 237ae01b8a3b07c0e82398b0bfdb14cb73d50fa0 (diff) | |
download | mupdf-6ec845bea34b5a7e42ae4685130daeb6cbae6c9e.tar.xz |
Implement check for range overlap between cmap splay tree nodes.
Diffstat (limited to 'source/pdf/pdf-cmap.c')
-rw-r--r-- | source/pdf/pdf-cmap.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/source/pdf/pdf-cmap.c b/source/pdf/pdf-cmap.c index 00e2afb7..6abacc56 100644 --- a/source/pdf/pdf-cmap.c +++ b/source/pdf/pdf-cmap.c @@ -362,7 +362,7 @@ dump_splay(cmap_splay *tree, unsigned int node, int depth, const char *pre) { int i; - if (node == EMPTY) + if (tree == NULL || node == EMPTY) return; for (i = 0; i < depth; i++) @@ -440,6 +440,19 @@ static void walk_splay(cmap_splay *tree, unsigned int node, void (*fn)(cmap_spla } #ifdef CHECK_SPLAY + +static int +tree_has_overlap(cmap_splay *tree, int node, int low, int high) +{ + if (tree[node].left != EMPTY) + if (tree_has_overlap(tree, tree[node].left, low, high)) + return 1; + if (tree[node].right != EMPTY) + if (tree_has_overlap(tree, tree[node].right, low, high)) + return 1; + return (tree[node].low < low && low < tree[node].high) || (tree[node].low < high && high < tree[node].high); +} + static void do_check(cmap_splay *node, void *arg) { @@ -451,6 +464,7 @@ do_check(cmap_splay *node, void *arg) tree[node->left].high < node->low)); assert(node->right == EMPTY || (tree[node->right].parent == num && node->high < tree[node->right].low)); + assert(!tree_has_overlap(tree, num, node->low, node->high)); } static void |