X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/044363451d877b3c9a278db74763c6c9991e49f0..3e3e0f988322e6cec76a78a4cdf68bd158d552e6:/sbr/fmt_scan.c diff --git a/sbr/fmt_scan.c b/sbr/fmt_scan.c index 1ea5e623..4416b54c 100644 --- a/sbr/fmt_scan.c +++ b/sbr/fmt_scan.c @@ -299,10 +299,20 @@ cpstripped (charstring_t dest, size_t max, char *str) prevCtrl = 0; #ifdef MULTIBYTE_SUPPORT - charstring_push_back_chars (dest, altstr ? altstr : str, char_len, w); - max -= w; - str += char_len; - altstr = NULL; + assert(w >= 0); + if (max >= (size_t) w) { + charstring_push_back_chars (dest, altstr ? altstr : str, char_len, w); + max -= w; + str += char_len; + altstr = NULL; + } else { + /* Not enough width available for the last character. Output + space(s) to fill. */ + while (max-- > 0) { + charstring_push_back (dest, ' '); + } + break; + } #else /* MULTIBYE_SUPPORT */ charstring_push_back (dest, *str++); --max;