aboutsummaryrefslogtreecommitdiffstats
path: root/src/libutil/util.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-04-02 11:37:19 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-04-02 11:37:19 +0100
commit063498ae63348de0c27eb0260cc7633bbc822df9 (patch)
tree07ed102978a60df8e6fdace1b4d188bd674888ec /src/libutil/util.c
parent6f072228e63748c79ef8fbf74dfffd0694a07247 (diff)
downloadrspamd-063498ae63348de0c27eb0260cc7633bbc822df9.tar.gz
rspamd-063498ae63348de0c27eb0260cc7633bbc822df9.zip
More fixes to utf8 lc.
Diffstat (limited to 'src/libutil/util.c')
-rw-r--r--src/libutil/util.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/libutil/util.c b/src/libutil/util.c
index 51445a8ba..645c3d2fe 100644
--- a/src/libutil/util.c
+++ b/src/libutil/util.c
@@ -677,7 +677,7 @@ rspamd_str_lc_utf8 (gchar *str, guint size)
{
const gchar *s = str, *p;
gchar *d = str;
- guint remain = size;
+ gint remain = size;
gint r;
gunichar uc;
@@ -686,12 +686,12 @@ rspamd_str_lc_utf8 (gchar *str, guint size)
uc = g_unichar_tolower (uc);
p = g_utf8_next_char (s);
- if (p - s == 0) {
- return;
+ if (p - s > remain) {
+ break;
}
r = g_unichar_to_utf8 (uc, d);
- g_assert (r > 0);
+ g_assert (remain >= r);
remain -= r;
s = p;
d += r;