shithub: asif

Download patch

ref: 43e22aa2ae51c403fdead4112e4afe184ef6d12e
parent: 44dfc2ed7f45a337358e8b113aa408a7cc2975a7
author: qwx <qwx@sciops.net>
date: Sat Aug 22 19:54:56 EDT 2020

kmp: fix used before set

--- a/kmp.c
+++ b/kmp.c
@@ -48,7 +48,8 @@
 	int n, i, j, *T;
 	VArray *v;
 
-	if(S.n < W.n)
+	n = S.n - W.n + 1;
+	if(n <= 0)
 		return nil;
 	v = valloc(n, sizeof(int));
 	T = tabfn(W);