]> git.sur5r.net Git - bacula/bacula/commitdiff
ebl fix missing free()
authorEric Bollengier <eric@eb.homelinux.org>
Thu, 5 Apr 2007 19:26:53 +0000 (19:26 +0000)
committerEric Bollengier <eric@eb.homelinux.org>
Thu, 5 Apr 2007 19:26:53 +0000 (19:26 +0000)
     make strip_prefix case independent

git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4514 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/patches/testing/breg.c
bacula/patches/testing/bregtest.c

index 976a17cc6a57e768ca93485279a66ee8c1118801..4f885adac842bc12ac7316316c5a8053bf286f91 100644 (file)
@@ -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;
 }
 
index 71eaad3b6b694b3251a7af371cbb6c486d158c46..07104544c32d04139c41499bd4cdbb09e499ad19 100644 (file)
@@ -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);