File harfbuzz-no-recurse-to-same-position.patch of Package harfbuzz

From 9cc1ed4fa68075b3b142a2737438109772dd0002 Mon Sep 17 00:00:00 2001
From: Behdad Esfahbod <behdad@behdad.org>
Date: Thu, 19 Nov 2015 12:39:09 -0800
Subject: [PATCH] Do not allow recursiving to same position and same lookup

This is just to make it harder to be extremely slow.  There definitely
are ways still, just harder.  Oh well... how do we tame this problem
without solving halting problem?!

Fixes https://github.com/behdad/harfbuzz/issues/174
---
 src/hb-ot-layout-gsubgpos-private.hh                     |   5 +++++
 test/shaping/fonts/sha1sum/MANIFEST                      |   1 +
 .../sha1sum/fab39d60d758cb586db5a504f218442cd1395725.ttf | Bin 0 -> 1894 bytes
 test/shaping/tests/fuzzed.tests                          |   1 +
 4 files changed, 7 insertions(+)
 create mode 100644 test/shaping/fonts/sha1sum/fab39d60d758cb586db5a504f218442cd1395725.ttf

diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh
index 36f6dd4..2873d0f 100644
--- a/src/hb-ot-layout-gsubgpos-private.hh
+++ b/src/hb-ot-layout-gsubgpos-private.hh
@@ -971,6 +971,11 @@ static inline bool apply_lookup (hb_apply_context_t *c,
     if (idx >= count)
       continue;
 
+    /* Don't recurse to ourself at same position.
+     * Note that this test is too naive, it doesn't catch longer loops. */
+    if (idx == 0 && lookupRecord[i].lookupListIndex == c->lookup_index)
+      continue;
+
     buffer->move_to (match_positions[idx]);
 
     unsigned int orig_len = buffer->backtrack_len () + buffer->lookahead_len ();
openSUSE Build Service is sponsored by