diff options
author | Francisco Couzo <franciscouzo@gmail.com> | 2018-01-17 21:59:03 -0300 |
---|---|---|
committer | TingPing <tingping@tingping.se> | 2018-01-18 04:49:10 -0500 |
commit | ee8926503c8f451ffbdb00760388e17edde343cb (patch) | |
tree | b78a7361309903bf530e65ccbece5e92060505e4 /src | |
parent | 7d7be8321613acf4a613894163b8468f107415de (diff) |
Prevent undefined behaviour on memcpy
Diffstat (limited to 'src')
-rw-r--r-- | src/fe-gtk/xtext.c | 6 |
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); |