diff options
Diffstat (limited to 'source3/libads/ads_struct.c')
-rw-r--r-- | source3/libads/ads_struct.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/source3/libads/ads_struct.c b/source3/libads/ads_struct.c index e546f2ae8a..7a03a2a80f 100644 --- a/source3/libads/ads_struct.c +++ b/source3/libads/ads_struct.c @@ -48,16 +48,18 @@ char *ads_build_path(const char *realm, const char *sep, const char *field, int strlcpy(ret,field, len); p=strtok(r,sep); - strlcat(ret, p, len); - - while ((p=strtok(NULL,sep))) { - char *s; - if (reverse) - asprintf(&s, "%s%s,%s", field, p, ret); - else - asprintf(&s, "%s,%s%s", ret, field, p); - free(ret); - ret = s; + if (p) { + strlcat(ret, p, len); + + while ((p=strtok(NULL,sep))) { + char *s; + if (reverse) + asprintf(&s, "%s%s,%s", field, p, ret); + else + asprintf(&s, "%s,%s%s", ret, field, p); + free(ret); + ret = s; + } } free(r); |