changeset 12842:5f15d53b610a

[gaim-migrate @ 15190] Turns out g_unichar_to_utf8 doesn't do NUL-termination for us. committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Thu, 12 Jan 2006 02:19:37 +0000
parents ab37a4cc477e
children d9686e688342
files plugins/spellchk.c
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/spellchk.c	Thu Jan 12 01:54:59 2006 +0000
+++ b/plugins/spellchk.c	Thu Jan 12 02:19:37 2006 +0000
@@ -125,9 +125,12 @@
 {
 	char buf[7];
 	gchar *lower = g_utf8_strdown(word, -1);
+	gint bytes;
 	gchar *ret;
 
-	g_unichar_to_utf8(g_unichar_toupper(g_utf8_get_char(word)), buf);
+	bytes = g_unichar_to_utf8(g_unichar_toupper(g_utf8_get_char(word)), buf);
+	buf[MIN(bytes, sizeof(buf) - 1)] = '\0';
+
 	ret = g_strconcat(buf, g_utf8_offset_to_pointer(lower, 1), NULL);
 	g_free(lower);