From: George Koehler Date: Sun, 13 Nov 2016 16:55:09 +0000 (-0500) Subject: Don't print a string after possibly freeing it. X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=e617f425032bccafe36657dcf615a6abaf026fd3;p=ack.git Don't print a string after possibly freeing it. new= newvar(name) takes ownership of the string and might free its memory. Don't print name. Do print new->v_name. Also #include for strcmp(). --- diff --git a/util/ack/svars.c b/util/ack/svars.c index 38e8f95b9..e540e5d02 100644 --- a/util/ack/svars.c +++ b/util/ack/svars.c @@ -4,6 +4,7 @@ * */ +#include #include "ack.h" #ifndef NORCSID @@ -81,7 +82,7 @@ void setsvar(char *name, char *str) { new= newvar(name); #ifdef DEBUG - if ( debug>=2 ) vprint("%s=%s\n", name, str) ; + if ( debug>=2 ) vprint("%s=%s\n", new->v_name, str) ; #endif new->v_type= string; new->v_value.v_string= str; @@ -92,7 +93,7 @@ void setpvar(char *name, char *(*rout)(void)) { new= newvar(name); #ifdef DEBUG - if ( debug>=2 ) vprint("%s= (*%o)()\n",name,rout) ; + if ( debug>=2 ) vprint("%s= (*%o)()\n", new->v_name, rout) ; #endif new->v_type= routine; new->v_value.v_routine= rout;