gchar *out = outbuf;
JISState state = JIS_ASCII;
- while (*in != '\0' && (out - outbuf) > outlen - 3) {
+ /*
+ * Loop outputs up to 3 bytes in each pass (aux kanji) and we
+ * need 1 byte to terminate the output
+ */
+ while (*in != '\0' && (out - outbuf) < outlen - 4) {
if (*in == ESC) {
in++;
if (*in == '$') {
gchar *out = outbuf;
JISState state = JIS_ASCII;
- while (*in != '\0' && (out - outbuf) < outlen - 3) {
+ /*
+ * Loop outputs up to 6 bytes in each pass (aux shift + aux
+ * kanji) and we need up to 4 bytes to terminate the output
+ * (ASCII shift + null)
+ */
+ while (*in != '\0' && (out - outbuf) < outlen - 10) {
if (IS_ASCII(*in)) {
K_OUT();
*out++ = *in++;
const guchar *in = inbuf;
gchar *out = outbuf;
+ /*
+ * Loop outputs up to 2 bytes in each pass and we need 1 byte
+ * to terminate the output
+ */
while (*in != '\0' && (out - outbuf) < outlen - 3) {
if (IS_ASCII(*in)) {
*out++ = *in++;
left = MAX_LINELEN - 1; \
} \
} else if (destp == (guchar *)dest && left < 7) { \
- if (isspace(*(destp - 1))) \
- destp--; \
- else if (is_plain_text && isspace(*srcp)) \
+ if (is_plain_text && isspace(*srcp)) \
srcp++; \
if (*srcp) { \
*destp++ = '\n'; \