From e3d755c5b2eff14486b80ca9a4bc7857aaf1c86c Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra@samba.org>
Date: Fri, 13 Feb 2004 22:06:25 +0000
Subject: Added Andrew Bartlett's patch to use an allocated buffer for
 count_chars. Jeremy. (This used to be commit
 cdbeb7d2ebcd4a298aabb3ed665560d219bb0d1c)

---
 source3/lib/util_str.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

(limited to 'source3')

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);
 }
 
-- 
cgit