From b74fedb146c49ba5374965b1a0d38d74a920b520 Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Mon, 29 May 2017 10:09:37 +0000 Subject: [PATCH] pcrs_compile_replacement(): Fix a clang warning when building with FUZZ support The warning was: "Address of stack memory associated with local variable 'length' is still referred to by the static variable 'length_stack' upon returning to the caller. This will be a dangling reference" For the fuzzing use case it didn't matter but it still shouldn't be done. While at it, remove a couple of variables that were only used to make debugging more convenient. --- pcrs.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/pcrs.c b/pcrs.c index 0553a53e..ebcfb360 100644 --- a/pcrs.c +++ b/pcrs.c @@ -1,4 +1,4 @@ -const char pcrs_rcs[] = "$Id: pcrs.c,v 1.50 2016/05/25 10:50:28 fabiankeil Exp $"; +const char pcrs_rcs[] = "$Id: pcrs.c,v 1.51 2016/12/24 16:00:49 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/pcrs.c,v $ @@ -241,16 +241,12 @@ extern pcrs_substitute *pcrs_compile_fuzzed_replacement(const char *replacement, static pcrs_substitute *pcrs_compile_replacement(const char *replacement, int trivialflag, int capturecount, int *errptr) { int i, k, l, quoted; - size_t length; char *text; pcrs_substitute *r; -#ifdef FUZZ - static const char *replacement_stack; - static const size_t *length_stack; - static pcrs_substitute *r_stack; - - replacement_stack = replacement; - length_stack = &length; +#ifndef FUZZ + size_t length; +#else + static size_t length; #endif i = k = l = quoted = 0; @@ -272,10 +268,6 @@ static pcrs_substitute *pcrs_compile_replacement(const char *replacement, int tr } memset(r, '\0', sizeof(pcrs_substitute)); -#ifdef FUZZ - r_stack = r; -#endif - length = strlen(replacement); if (NULL == (text = (char *)malloc(length + 1))) -- 2.39.2