From 20ecae9a5888c168ad05cb26d1177061f3f9378f Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 13 Jan 2003 12:42:20 +0000 Subject: Accessing data after it's been free()ed really is a no-no... Andrew Bartlett (This used to be commit 6e821285a4aacfc0031957b88ddbec73d7e1dc11) --- source3/lib/util_str.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'source3/lib/util_str.c') diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c index 7ffd71bde9..4d3a808f16 100644 --- a/source3/lib/util_str.c +++ b/source3/lib/util_str.c @@ -308,8 +308,22 @@ char *skip_string(char *buf,size_t n) size_t str_charnum(const char *s) { - push_ucs2(NULL, tmpbuf,s, sizeof(tmpbuf), STR_TERMINATE); - return strlen_w(tmpbuf); + uint16 tmpbuf2[sizeof(pstring)]; + push_ucs2(NULL, tmpbuf2,s, sizeof(tmpbuf2), STR_TERMINATE); + return strlen_w(tmpbuf2); +} + +/******************************************************************* + Count the number of characters in a string. Normally this will + be the same as the number of bytes in a string for single byte strings, + but will be different for multibyte. +********************************************************************/ + +size_t str_ascii_charnum(const char *s) +{ + pstring tmpbuf2; + push_ascii(tmpbuf2, s, sizeof(tmpbuf2), STR_TERMINATE); + return strlen(tmpbuf2); } /******************************************************************* -- cgit