diff options
author | Jeremy Allison <jra@samba.org> | 2004-02-13 22:06:23 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2004-02-13 22:06:23 +0000 |
commit | 94cb77579b3c4834f11265ce0f3cb70f474181a8 (patch) | |
tree | 885e23691b003fe70eb662cdba6e1a341329934e | |
parent | 8b9cdc96b4886e415eccf0a8aa57adff637570fe (diff) | |
download | samba-94cb77579b3c4834f11265ce0f3cb70f474181a8.tar.gz samba-94cb77579b3c4834f11265ce0f3cb70f474181a8.tar.bz2 samba-94cb77579b3c4834f11265ce0f3cb70f474181a8.zip |
Added Andrew Bartlett's patch to use an allocated buffer for count_chars.
Jeremy.
(This used to be commit 4ec9e330787cbc01849a91573f760f639b28be7e)
-rw-r--r-- | source3/lib/util_str.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c index 2d1f596c97..cde6b2e7a1 100644 --- a/source3/lib/util_str.c +++ b/source3/lib/util_str.c @@ -557,10 +557,16 @@ size_t count_chars(const char *s,char c) { smb_ucs2_t *ptr; int count; - push_ucs2(NULL, tmpbuf,s, sizeof(tmpbuf), STR_TERMINATE); - for(count=0,ptr=tmpbuf;*ptr;ptr++) + smb_ucs2_t *alloc_tmpbuf; + + if (push_ucs2_allocate(&alloc_tmpbuf, s) == (size_t)-1) { + return 0; + } + + for(count=0,ptr=alloc_tmpbuf;*ptr;ptr++) if(*ptr==UCS2_CHAR(c)) count++; + return(count); } |