From 9019ac689db670dc09ebe7c6fcadf62a7f10cb3e Mon Sep 17 00:00:00 2001 From: John Darrington Date: Thu, 11 Aug 2016 21:19:36 +0200 Subject: [PATCH] Fix possible buffer overrun Found by cppcheck --- src/ui/gui/help-menu.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ui/gui/help-menu.c b/src/ui/gui/help-menu.c index aeef8c10c4..b5b38757c3 100644 --- a/src/ui/gui/help-menu.c +++ b/src/ui/gui/help-menu.c @@ -148,7 +148,7 @@ online_help (const char *page) { gchar **tokens = NULL; const int maxtokens = 5; - int idx = 0; + int idx ; argv[1] = g_strdup_printf ("file://%s#%s", relocate (DOCDIR "/pspp.xml"), page); /* The page will be translated to the htmlfilename @@ -157,7 +157,8 @@ online_help (const char *page) QUICK-CLUSTER QUICK-CLUSTER.html which is valid for the multiple page html doc*/ tokens = g_strsplit (page, "#", maxtokens); - for(;tokens[idx] && idx < maxtokens;idx++); + for (idx = 0; idx < maxtokens && tokens[idx]; idx++) + ; htmlfilename = g_strdup_printf ("%s.html", tokens[idx-1]); g_strfreev (tokens); } -- 2.30.2