summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2008-01-16 15:51:52 +0100
committerGünther Deschner <gd@samba.org>2008-01-16 16:06:15 +0100
commitfbcc7820c620d45f02ab75e08d840e3a676fe671 (patch)
tree436f0cf1882b0cff6fe62fb4066c8635a5b4d22e
parentbe9b7a6414cda06b400d654f73f17327a1a6f69c (diff)
downloadsamba-fbcc7820c620d45f02ab75e08d840e3a676fe671.tar.gz
samba-fbcc7820c620d45f02ab75e08d840e3a676fe671.tar.bz2
samba-fbcc7820c620d45f02ab75e08d840e3a676fe671.zip
Fix memleak in ads_build_path().
Guenther (This used to be commit b7a06b54e0a58c4cd6c5351b1e4a0a2c253cfea1)
-rw-r--r--source3/libads/ads_struct.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/source3/libads/ads_struct.c b/source3/libads/ads_struct.c
index 041878916e..44bcdf76ea 100644
--- a/source3/libads/ads_struct.c
+++ b/source3/libads/ads_struct.c
@@ -32,18 +32,23 @@ char *ads_build_path(const char *realm, const char *sep, const char *field, int
r = SMB_STRDUP(realm);
- if (!r || !*r)
+ if (!r || !*r) {
return r;
+ }
- for (p=r; *p; p++)
- if (strchr(sep, *p))
+ for (p=r; *p; p++) {
+ if (strchr(sep, *p)) {
numbits++;
+ }
+ }
len = (numbits+1)*(strlen(field)+1) + strlen(r) + 1;
ret = (char *)SMB_MALLOC(len);
- if (!ret)
+ if (!ret) {
+ free(r);
return NULL;
+ }
strlcpy(ret,field, len);
p=strtok(r,sep);
@@ -57,7 +62,8 @@ char *ads_build_path(const char *realm, const char *sep, const char *field, int
else
asprintf(&s, "%s,%s%s", ret, field, p);
free(ret);
- ret = s;
+ ret = SMB_STRDUP(s);
+ free(s);
}
}