From: Hartmut Holzgraefe Date: Sun, 7 Apr 2002 19:46:45 +0000 (+0000) Subject: fix and regression test for Bug #16473 X-Git-Tag: php-4.3.0dev-ZendEngine2-Preview1~811 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=954dbb2d3554080dbfe84c4c6f7ee2017c48807e;p=php fix and regression test for Bug #16473 --- diff --git a/ext/standard/levenshtein.c b/ext/standard/levenshtein.c index 47a8de7540..f5c23687cf 100644 --- a/ext/standard/levenshtein.c +++ b/ext/standard/levenshtein.c @@ -40,33 +40,31 @@ static int reference_levdist(const char *s1, int l1, if((l1>LEVENSHTEIN_MAX_LENTH)||(l2>LEVENSHTEIN_MAX_LENTH)) return -1; - if(!(p1=emalloc(l2*sizeof(int)))) { + if(!(p1=emalloc((l2+1)*sizeof(int)))) { return -2; } - if(!(p2=emalloc(l2*sizeof(int)))) { + if(!(p2=emalloc((l2+1)*sizeof(int)))) { free(p1); return -2; } - p1[0]=(s1[0]==s2[0])?0:cost_rep; + for(i2=0;i2<=l2;i2++) + p1[i2] = i2*cost_ins; - for(i2=1;i2