summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2004-02-13 22:06:25 +0000
committerJeremy Allison <jra@samba.org>2004-02-13 22:06:25 +0000
commite3d755c5b2eff14486b80ca9a4bc7857aaf1c86c (patch)
treef364a171e2c371cf364f3011a8a9876d60c2e988
parentb545a8de0a605edda11cab322dab0ad26b6cebd1 (diff)
downloadsamba-e3d755c5b2eff14486b80ca9a4bc7857aaf1c86c.tar.gz
samba-e3d755c5b2eff14486b80ca9a4bc7857aaf1c86c.tar.bz2
samba-e3d755c5b2eff14486b80ca9a4bc7857aaf1c86c.zip
Added Andrew Bartlett's patch to use an allocated buffer for count_chars.
Jeremy. (This used to be commit cdbeb7d2ebcd4a298aabb3ed665560d219bb0d1c)
-rw-r--r--source3/lib/util_str.c10
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);
}