From e617f425032bccafe36657dcf615a6abaf026fd3 Mon Sep 17 00:00:00 2001 From: George Koehler Date: Sun, 13 Nov 2016 11:55:09 -0500 Subject: [PATCH] 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(). --- util/ack/svars.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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;