summaryrefslogtreecommitdiff
path: root/source3/libads
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2006-06-13 18:09:04 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:17:24 -0500
commitc0e4753cfcbece7aaf2a96726146b225c9925932 (patch)
tree5f22d10caae4785e79e8b3eb5a542a344dc74f79 /source3/libads
parent4d1688bf6bac74df93eb4c3e8f540f541a25390d (diff)
downloadsamba-c0e4753cfcbece7aaf2a96726146b225c9925932.tar.gz
samba-c0e4753cfcbece7aaf2a96726146b225c9925932.tar.bz2
samba-c0e4753cfcbece7aaf2a96726146b225c9925932.zip
r16199: Fix Klocwork #1 - ensure we test the first
strtok for NULL. Jeremy. (This used to be commit 98751e8190317416de56b4a19a489c5f4b7d6bc9)
Diffstat (limited to 'source3/libads')
-rw-r--r--source3/libads/ads_struct.c22
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);