[GSUB] Fix context_length handling in Ligature too
diff --git a/src/hb-ot-layout-gsubgpos-private.h b/src/hb-ot-layout-gsubgpos-private.h
index f5b900f..f9a1f6b 100644
--- a/src/hb-ot-layout-gsubgpos-private.h
+++ b/src/hb-ot-layout-gsubgpos-private.h
@@ -221,7 +221,7 @@
 {
   /* First guess */
   if (HB_UNLIKELY (buffer->in_pos + inputCount > buffer->in_length ||
-		   context_length < inputCount))
+		   inputCount > context_length))
     return false;
 
   return match_input (LOOKUP_ARGS,
@@ -435,7 +435,8 @@
 {
   /* First guess */
   if (HB_UNLIKELY (buffer->out_pos < backtrackCount ||
-		   buffer->in_pos + inputCount + lookaheadCount > buffer->in_length))
+		   buffer->in_pos + inputCount + lookaheadCount > buffer->in_length ||
+		   inputCount + lookaheadCount > context_length))
     return false;
 
   unsigned int offset;