From 1f76e2c3f3a49432253b695bb92760f4bef44359 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Wed, 3 May 2017 17:41:14 +0200 Subject: [PATCH] Small code refactor to work around mis-detect static code analyzer. --- source/helper.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/helper.c b/source/helper.c index 4dcfc309..d31a4e20 100644 --- a/source/helper.c +++ b/source/helper.c @@ -684,9 +684,12 @@ unsigned int levenshtein ( const char *needle, const glong needlelen, const char return UINT_MAX; } unsigned int column[needlelen + 1]; - for ( glong y = 0; y <= needlelen; y++ ) { + for ( glong y = 0; y < needlelen; y++ ) { column[y] = y; } + // Removed out of the loop, otherwise static code analyzers think it is unset.. silly but true. + // old loop: for ( glong y = 0; y <= needlelen; y++) + column[needlelen] = needlelen; for ( glong x = 1; x <= haystacklen; x++ ) { const char *needles = needle; column[0] = x;