Fix bug 5698 - mixup of TALLOC/malloc. Spotted by Douglas Wegscheid <Douglas_E_Wegsch...
authorJeremy Allison <jra@samba.org>
Thu, 21 Aug 2008 17:25:02 +0000 (10:25 -0700)
committerJeremy Allison <jra@samba.org>
Thu, 21 Aug 2008 17:25:02 +0000 (10:25 -0700)
Jeremy.

source/lib/util_str.c

index 5f26cc80f8c99e6ebc503d2e72576ab94ea076af..9f952abf1010c6440fceb1f23552ddd03e466526 100644 (file)
@@ -2008,6 +2008,7 @@ bool str_list_sub_basic( char **list, const char *smb_name,
 
 bool str_list_substitute(char **list, const char *pattern, const char *insert)
 {
+       TALLOC_CTX *ctx = list;
        char *p, *s, *t;
        ssize_t ls, lp, li, ld, i, d;
 
@@ -2030,7 +2031,7 @@ bool str_list_substitute(char **list, const char *pattern, const char *insert)
                        t = *list;
                        d = p -t;
                        if (ld) {
-                               t = (char *) SMB_MALLOC(ls +ld +1);
+                               t = TALLOC_ARRAY(ctx, char, ls +ld +1);
                                if (!t) {
                                        DEBUG(0,("str_list_substitute: "
                                                "Unable to allocate memory"));
@@ -2038,7 +2039,7 @@ bool str_list_substitute(char **list, const char *pattern, const char *insert)
                                }
                                memcpy(t, *list, d);
                                memcpy(t +d +li, p +lp, ls -d -lp +1);
-                               SAFE_FREE(*list);
+                               TALLOC_FREE(*list);
                                *list = t;
                                ls += ld;
                                s = t +d +li;