From a77c5c09100ef56940546b543dd1c515529ca4bb Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Sat, 3 Mar 2012 22:12:46 +0000 Subject: Fix Savannah bug #35410: handle escape chars in filter/filter-out Also add a valgrind suppression file for Guile-enabled make. --- function.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'function.c') diff --git a/function.c b/function.c index 5acbb76..d68bc4d 100644 --- a/function.c +++ b/function.c @@ -905,7 +905,6 @@ struct a_pattern char *str; char *percent; int length; - int save_c; }; static char * @@ -928,7 +927,9 @@ func_filter_filterout (char *o, char **argv, const char *funcname) char *p; unsigned int len; - /* Chop ARGV[0] up into patterns to match against the words. */ + /* Chop ARGV[0] up into patterns to match against the words. + We don't need to preserve it because our caller frees all the + argument memory anyway. */ pattail = &pathead; while ((p = find_next_token (&pat_iterator, &len)) != 0) @@ -942,12 +943,13 @@ func_filter_filterout (char *o, char **argv, const char *funcname) ++pat_iterator; pat->str = p; - pat->length = len; - pat->save_c = p[len]; p[len] = '\0'; pat->percent = find_percent (p); if (pat->percent == 0) literals++; + + /* find_percent() might shorten the string so LEN is wrong. */ + pat->length = strlen (pat->str); } *pattail = 0; @@ -1029,9 +1031,6 @@ func_filter_filterout (char *o, char **argv, const char *funcname) --o; } - for (pp = pathead; pp != 0; pp = pp->next) - pp->str[pp->length] = pp->save_c; - if (hashing) hash_free (&a_word_table, 0); @@ -2377,7 +2376,7 @@ handle_function (char **op, const char **stringp) if (entry_p->expand_args) for (argvp=argv; *argvp != 0; ++argvp) free (*argvp); - if (abeg) + else if (abeg) free (abeg); return 1; -- cgit v1.2.3