From 7e6a24f9b6908cfb37632a68e0eb797f2624981e Mon Sep 17 00:00:00 2001 From: QC Date: Sat, 10 Jan 2015 15:13:10 +0100 Subject: [PATCH] Make analysis happy and prefer heap over stack. --- source/rofi.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/source/rofi.c b/source/rofi.c index 435eb35c..4f95c6f7 100644 --- a/source/rofi.c +++ b/source/rofi.c @@ -781,15 +781,18 @@ static int levenshtein ( const char *s, const char *t ) { int ls = strlen ( s ), lt = strlen ( t ); size_t array_length = ( ls + 1 ) * ( lt + 1 ); + // For some reason Coverity does not get that I initialize the // array in for loop. - int d[array_length]; + int *d = g_malloc_n ( array_length, sizeof ( int ) ); for ( size_t i = 0; i < array_length; i++ ) { d[i] = -1; } - return dist ( s, t, d, ls, lt, 0, 0 ); + int retv = dist ( s, t, d, ls, lt, 0, 0 ); + g_free ( d ); + return retv; } static void window_set_opacity ( Display *display, Window box, unsigned int opacity )