1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-23 09:57:40 +03:00

Added Andrew Bartlett's patch to use an allocated buffer for count_chars.

Jeremy.
This commit is contained in:
Jeremy Allison -
parent a7d4a6d116
commit 4ec9e33078

View File

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