summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorFrancisco Couzo <franciscouzo@gmail.com>2018-01-17 21:59:03 -0300
committerTingPing <tingping@tingping.se>2018-01-18 04:49:10 -0500
commitee8926503c8f451ffbdb00760388e17edde343cb (patch)
treeb78a7361309903bf530e65ccbece5e92060505e4
parent7d7be8321613acf4a613894163b8468f107415de (diff)
Prevent undefined behaviour on memcpy
-rw-r--r--src/fe-gtk/xtext.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/fe-gtk/xtext.c b/src/fe-gtk/xtext.c
index 35242fe0..6151f5b6 100644
--- a/src/fe-gtk/xtext.c
+++ b/src/fe-gtk/xtext.c
@@ -4677,9 +4677,11 @@ gtk_xtext_append_indent (xtext_buffer *buf,
 	ent = g_malloc (left_len + right_len + 2 + 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] = ' ';
-	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;
 
 	left_width = gtk_xtext_text_width (buf->xtext, left_text, left_len);