summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2004-09-15 22:49:23 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 10:52:40 -0500
commit3ef0710fa4f487e8887a8c16714c6443009e4a47 (patch)
tree4ad47fd76ee5f23267a9ec513b15b11567fe3a59 /source3/lib
parent20e9f051e2fe5867e11988139399bac692112fc6 (diff)
downloadsamba-3ef0710fa4f487e8887a8c16714c6443009e4a47.tar.gz
samba-3ef0710fa4f487e8887a8c16714c6443009e4a47.tar.bz2
samba-3ef0710fa4f487e8887a8c16714c6443009e4a47.zip
r2361: Fix the appalling toktocliplist() fn. Bug found by Luis Benvenutto.
Jeremy. (This used to be commit d434d8e2b47bc8553ee04bd7211f622e3fcbb7fb)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/util_str.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c
index 6eee62c14a..65a616ad41 100644
--- a/source3/lib/util_str.c
+++ b/source3/lib/util_str.c
@@ -134,17 +134,20 @@ char **toktocliplist(int *ctok, const char *sep)
*ctok=ictok;
s=(char *)last_ptr;
- if (!(ret=iret=malloc(ictok*sizeof(char *))))
+ if (!(ret=iret=malloc((ictok+1)*sizeof(char *))))
return NULL;
while(ictok--) {
*iret++=s;
- while(*s++)
- ;
- while(!*s)
- s++;
+ if (ictok > 0) {
+ while(*s++)
+ ;
+ while(!*s)
+ s++;
+ }
}
+ ret[*ctok] = NULL;
return ret;
}