diff options
author | Lennart Poettering <lennart@poettering.net> | 2006-05-16 00:04:14 +0000 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2006-05-16 00:04:14 +0000 |
commit | 713637cf424a6b4b177c0d353d862ab0ea916d4e (patch) | |
tree | b0bd556d40250ee10a6cc8431c231a9ac39a2227 /src/polypcore | |
parent | 19167a1a2d9bdff5a6685f1d14dc47b2aa7dad5a (diff) |
* fix segfault in pa_utf8_validate()
* remove some compiler warnings
* use our own pa_xmalloc() implementation instead of libc's malloc()
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@874 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'src/polypcore')
-rw-r--r-- | src/polypcore/utf8.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/polypcore/utf8.c b/src/polypcore/utf8.c index 03865507..95b73d52 100644 --- a/src/polypcore/utf8.c +++ b/src/polypcore/utf8.c @@ -34,6 +34,7 @@ #include <string.h> #include "utf8.h" +#include "xmalloc.h" #define FILTER_CHAR '_' @@ -67,11 +68,11 @@ static const char* utf8_validate (const char *str, char *output) { int size; uint8_t *o; - o = output; - for (p = (uint8_t*)str; *p; p++, o++) { + o = (uint8_t*) output; + for (p = (const uint8_t*) str; *p; p++) { if (*p < 128) { if (o) - *output = *p; + *o = *p; } else { last = p; @@ -122,6 +123,9 @@ ONE_REMAINING: o += size - 1; } + if (o) + o++; + continue; error: @@ -131,6 +135,9 @@ error: } else goto failure; } + + if (o) + o++; } if (o) { @@ -151,8 +158,7 @@ const char* pa_utf8_valid (const char *str) { const char* pa_utf8_filter (const char *str) { char *new_str; - new_str = malloc(strlen(str) + 1); - assert(new_str); + new_str = pa_xnew(char, strlen(str) + 1); return utf8_validate(str, new_str); } |