From 94cb77579b3c4834f11265ce0f3cb70f474181a8 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 13 Feb 2004 22:06:23 +0000 Subject: Added Andrew Bartlett's patch to use an allocated buffer for count_chars. Jeremy. (This used to be commit 4ec9e330787cbc01849a91573f760f639b28be7e) --- 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