Commit Diff


commit - e4c510c1d83fe01247b6f59d855dffad81e4f26a
commit + 60c6aae16f7ac9b67326d34fca6de68561e97c0e
blob - 4d56f531ab2bad65855c0e64d94dee310c5a3e8e
blob + 09e07bf366400bc6bbc7e18eba214c253d078cd7
--- lib/diff_myers.c
+++ lib/diff_myers.c
@@ -782,6 +782,8 @@ shift_sqrt(int val)
 		i <<= 1;
         return i;
 }
+
+#define DIFF_EFFORT_MIN 1024
 
 /* Myers "Divide et Impera": tracing forwards from the start and backwards from
  * the end to find a midpoint that divides the problem into smaller chunks.
@@ -823,6 +825,9 @@ diff_algo_myers_divide(const struct diff_algo_config *
 	int *kd_backward = kd_buf + kd_len;
 	int max_effort = shift_sqrt(max/2);
 
+	if (max_effort < DIFF_EFFORT_MIN)
+		max_effort = DIFF_EFFORT_MIN;
+
 	/* The 'k' axis in Myers spans positive and negative indexes, so point
 	 * the kd to the middle.
 	 * It is then possible to index from -max/2 .. max/2. */