summaryrefslogtreecommitdiff
path: root/src/charset/codecs/codec_utf8.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/charset/codecs/codec_utf8.c')
-rw-r--r--src/charset/codecs/codec_utf8.c19
1 files changed, 7 insertions, 12 deletions
diff --git a/src/charset/codecs/codec_utf8.c b/src/charset/codecs/codec_utf8.c
index 4016ebc..6117fe6 100644
--- a/src/charset/codecs/codec_utf8.c
+++ b/src/charset/codecs/codec_utf8.c
@@ -5,6 +5,7 @@
* Copyright 2007 John-Mark Bell <jmb@netsurf-browser.org>
*/
+#include <assert.h>
#include <stdlib.h>
#include <string.h>
@@ -176,8 +177,7 @@ parserutils_error charset_utf8_codec_encode(parserutils_charset_codec *codec,
UTF8_FROM_UCS4(pwrite[0], dest, destlen, error);
if (error != PARSERUTILS_OK) {
uint32_t len;
- if (error != PARSERUTILS_NOMEM)
- abort();
+ assert(error == PARSERUTILS_NOMEM);
/* Insufficient output buffer space */
for (len = 0; len < c->write_len; len++) {
@@ -203,12 +203,10 @@ parserutils_error charset_utf8_codec_encode(parserutils_charset_codec *codec,
UTF8_FROM_UCS4(towrite[0], dest, destlen, error);
if (error != PARSERUTILS_OK) {
uint32_t len;
- if (error != PARSERUTILS_NOMEM)
- abort();
+ assert(error == PARSERUTILS_NOMEM);
/* Insufficient output space */
- if (towritelen >= WRITE_BUFSIZE)
- abort();
+ assert(towritelen < WRITE_BUFSIZE);
c->write_len = towritelen;
@@ -337,8 +335,7 @@ parserutils_error charset_utf8_codec_decode(parserutils_charset_codec *codec,
/* Failed to resolve an incomplete character and
* ran out of buffer space. No recovery strategy
* possible, so explode everywhere. */
- if ((orig_l + ol) - l == 0)
- abort();
+ assert((orig_l + ol) - l != 0);
/* Report memory exhaustion case from above */
if (error != PARSERUTILS_OK)
@@ -441,8 +438,7 @@ parserutils_error charset_utf8_codec_read_char(charset_utf8_codec *c,
return error;
} else if (error == PARSERUTILS_NEEDDATA) {
/* Incomplete input sequence */
- if (*sourcelen >= INVAL_BUFSIZE)
- abort();
+ assert(*sourcelen < INVAL_BUFSIZE);
memmove(c->inval_buf, *source, *sourcelen);
c->inval_buf[*sourcelen] = '\0';
@@ -480,8 +476,7 @@ parserutils_error charset_utf8_codec_read_char(charset_utf8_codec *c,
if (error != PARSERUTILS_OK) {
if (error == PARSERUTILS_NEEDDATA) {
/* Need more data to be sure */
- if (*sourcelen > INVAL_BUFSIZE)
- abort();
+ assert(*sourcelen < INVAL_BUFSIZE);
memmove(c->inval_buf, *source, *sourcelen);
c->inval_buf[*sourcelen] = '\0';