Prevent undefined behaviour on memcpy

This commit is contained in:
Francisco Couzo 2018-01-17 21:59:03 -03:00 committed by TingPing
parent 7d7be83216
commit ee8926503c

View File

@ -4677,9 +4677,11 @@ gtk_xtext_append_indent (xtext_buffer *buf,
ent = g_malloc (left_len + right_len + 2 + sizeof (textentry)); ent = g_malloc (left_len + right_len + 2 + sizeof (textentry));
str = (unsigned char *) ent + sizeof (textentry); str = (unsigned char *) ent + sizeof (textentry);
memcpy (str, left_text, left_len); if (left_len)
memcpy (str, left_text, left_len);
str[left_len] = ' '; str[left_len] = ' ';
memcpy (str + left_len + 1, right_text, right_len); if (right_len)
memcpy (str + left_len + 1, right_text, right_len);
str[left_len + 1 + right_len] = 0; str[left_len + 1 + right_len] = 0;
left_width = gtk_xtext_text_width (buf->xtext, left_text, left_len); left_width = gtk_xtext_text_width (buf->xtext, left_text, left_len);