xtext: Fix invalid utf-8 from truncation

This commit is contained in:
Patrick Griffis 2018-01-19 04:29:07 -05:00
parent 5d3bf39103
commit 4cdf6460b6
1 changed files with 2 additions and 4 deletions

View File

@ -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 = g_malloc (len + 1 + sizeof (textentry));
ent->str = (unsigned char *) ent + sizeof (textentry); ent->str = (unsigned char *) ent + sizeof (textentry);
ent->str_len = len; safe_strcpy (ent->str, text, len);
if (len) ent->str_len = strlen (ent->str); /* Possibly truncated */
memcpy (ent->str, text, len);
ent->str[len] = 0;
ent->indent = 0; ent->indent = 0;
ent->left_len = -1; ent->left_len = -1;