[draw] Check len while checking for UTF-8 chars

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-04-28 07:35:03 +02:00
parent afdc57bc97
commit 84df60e11b
1 changed files with 1 additions and 1 deletions

View File

@ -228,7 +228,7 @@ draw_text(DrawCtx *ctx,
/* we can't blindly null the char, we need to check if it's not part of /* we can't blindly null the char, we need to check if it's not part of
* a multi byte char: if mbtowc return -1, we know that we must go back * a multi byte char: if mbtowc return -1, we know that we must go back
* in the string to find the beginning of the multi byte char */ * in the string to find the beginning of the multi byte char */
while(mbtowc(NULL, buf + len, a_strlen(buf + len)) < 0) while(len && mbtowc(NULL, buf + len, a_strlen(buf + len)) < 0)
len--; len--;
buf[len] = '\0'; buf[len] = '\0';
} }