diff options
author | Jeremy Allison <jra@samba.org> | 2004-09-15 22:49:23 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 10:52:40 -0500 |
commit | d434d8e2b47bc8553ee04bd7211f622e3fcbb7fb (patch) | |
tree | c17ef913f1b2e50e9ea1804856f844cd6f9ee398 /source/lib/util_str.c | |
parent | d6b26f9db76e81d65b7630e46af99fe03a982ec6 (diff) | |
download | samba-d434d8e2b47bc8553ee04bd7211f622e3fcbb7fb.tar.gz samba-d434d8e2b47bc8553ee04bd7211f622e3fcbb7fb.tar.xz samba-d434d8e2b47bc8553ee04bd7211f622e3fcbb7fb.zip |
r2361: Fix the appalling toktocliplist() fn. Bug found by Luis Benvenutto.
Jeremy.
Diffstat (limited to 'source/lib/util_str.c')
-rw-r--r-- | source/lib/util_str.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/source/lib/util_str.c b/source/lib/util_str.c index 6eee62c14aa..65a616ad419 100644 --- a/source/lib/util_str.c +++ b/source/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; } |