diff options
author | John Mark Bell <jmb@netsurf-browser.org> | 2005-05-23 22:27:37 +0000 |
---|---|---|
committer | John Mark Bell <jmb@netsurf-browser.org> | 2005-05-23 22:27:37 +0000 |
commit | fd99b1e9065868483b5cbaf303a3cdd59417d013 (patch) | |
tree | d5a74608321d659b74bb6975abeda13e46542e55 /utils/utf8.c | |
parent | e2fb0a94cd4283c09e63e0c616bcba5df4342d48 (diff) | |
download | netsurf-fd99b1e9065868483b5cbaf303a3cdd59417d013.tar.gz |
[project @ 2005-05-23 22:27:37 by jmb]
Tighten up entry conditions
svn path=/import/netsurf/; revision=1735
Diffstat (limited to 'utils/utf8.c')
-rw-r--r-- | utils/utf8.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/utils/utf8.c b/utils/utf8.c index 2676e8881..b2a219ced 100644 --- a/utils/utf8.c +++ b/utils/utf8.c @@ -84,7 +84,7 @@ size_t utf8_from_ucs4(size_t c, char *s) { size_t l = 0; - if (c > 0x7FFFFFFF) + if (c > 0x7FFFFFFF || s == NULL) assert(0); else if (c < 0x80) { *s = (char)c; @@ -139,6 +139,9 @@ size_t utf8_length(const char *s) { const char *__s = s; int l = 0; + + assert(__s != NULL); + while (*__s != '\0') { if ((*__s & 0x80) == 0x00) __s += 1; @@ -169,6 +172,8 @@ size_t utf8_length(const char *s) */ size_t utf8_prev(const char *s, size_t o) { + assert(s != NULL); + while (o != 0 && !(((s[--o] & 0x80) == 0x00) || ((s[o] & 0xC0) == 0xC0))) /* do nothing */; @@ -186,6 +191,8 @@ size_t utf8_prev(const char *s, size_t o) */ size_t utf8_next(const char *s, size_t l, size_t o) { + assert(s != NULL); + while (o != l && !(((s[++o] & 0x80) == 0x00) || ((s[o] & 0xC0) == 0xC0))) /* do nothing */; |