From: Eric Bollengier Date: Thu, 5 Apr 2007 19:26:53 +0000 (+0000) Subject: ebl fix missing free() X-Git-Tag: Release-7.0.0~6613 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=cb2886ac98cc8374232df399d18f8d8a0be5f0ab;p=bacula%2Fbacula ebl fix missing free() make strip_prefix case independent git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4514 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/patches/testing/breg.c b/bacula/patches/testing/breg.c index 976a17cc6a..4f885adac8 100644 --- a/bacula/patches/testing/breg.c +++ b/bacula/patches/testing/breg.c @@ -378,15 +378,15 @@ char *bregexp_build_where(char *strip_prefix, char *add_prefix, char *add_suffix) { - /* strip_prefix = !strip_prefix!! 4 bytes + /* strip_prefix = !strip_prefix!!i 4 bytes * add_prefix = !^!add_prefix! 5 bytes - * add_suffix = !([^/])$!$1.add_suffix! 14 bytes + * add_suffix = !([^/])$!$1add_suffix! 13 bytes */ int len=0; char sep = '!'; - int str_size = (strlen(strip_prefix) + 4 + - strlen(add_prefix) + 5 + - strlen(add_suffix) + 14) * 2 + 1; + int str_size = (strip_prefix?strlen(strip_prefix)+4:0 + + add_prefix?strlen(add_prefix)+5:0 + /* escape + 3*, + \0 */ + add_suffix?strlen(add_suffix)+14:0 ) * 2 + 3 + 1; POOLMEM *ret = get_memory(str_size); POOLMEM *str_tmp = get_memory(str_size); @@ -394,7 +394,7 @@ char *bregexp_build_where(char *strip_prefix, *str_tmp = *ret = '\0'; if (strip_prefix) { - len += bsnprintf(ret, str_size - len, "!%s!!", + len += bsnprintf(ret, str_size - len, "!%s!!i", bregexp_escape_string(str_tmp, strip_prefix, sep)); } @@ -412,6 +412,8 @@ char *bregexp_build_where(char *strip_prefix, bregexp_escape_string(str_tmp, add_prefix, sep)); } + free_pool_memory(str_tmp); + return ret; } diff --git a/bacula/patches/testing/bregtest.c b/bacula/patches/testing/bregtest.c index 71eaad3b6b..07104544c3 100644 --- a/bacula/patches/testing/bregtest.c +++ b/bacula/patches/testing/bregtest.c @@ -62,7 +62,7 @@ static void usage() int main(int argc, char *const *argv) { - printf("%s\n", bregexp_build_where("/tmp", "/opt", ".old")); + printf("%s\n", bregexp_build_where("/tmp", NULL, ".old")); exit(0);