summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorPatrick Griffis <tingping@tingping.se>2018-01-19 04:29:07 -0500
committerPatrick Griffis <tingping@tingping.se>2018-02-06 17:06:50 -0500
commit4cdf6460b666a187c791c26c2f693f1f5adde3ee (patch)
treeffea2fa281ab86620dfb79b57ebf1b06486fcfda
parent5d3bf391032b572eb571c8a31ead645aae4edba9 (diff)
xtext: Fix invalid utf-8 from truncation
-rw-r--r--src/fe-gtk/xtext.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/fe-gtk/xtext.c b/src/fe-gtk/xtext.c
index 1798647e..fef00c51 100644
--- a/src/fe-gtk/xtext.c
+++ b/src/fe-gtk/xtext.c
@@ -4718,10 +4718,8 @@ gtk_xtext_append (xtext_buffer *buf, unsigned char *text, int len, time_t stamp)
 
 	ent = g_malloc (len + 1 + sizeof (textentry));
 	ent->str = (unsigned char *) ent + sizeof (textentry);
-	ent->str_len = len;
-	if (len)
-		memcpy (ent->str, text, len);
-	ent->str[len] = 0;
+	safe_strcpy (ent->str, text, len);
+	ent->str_len = strlen (ent->str); /* Possibly truncated */
 	ent->indent = 0;
 	ent->left_len = -1;