summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2023-06-18 13:01:14 +0200
committerPřemysl Eric Janouch <p@janouch.name>2023-06-18 13:01:14 +0200
commit6bd40f3ec174ce7bdbb327b7488dc6045e24a504 (patch)
treeaf445611de19671118e479dc168513a1d6a19933
parenteb925f18c821fc5c49bb184ce842364e8194a0eb (diff)
downloadnncmpp-6bd40f3ec174ce7bdbb327b7488dc6045e24a504.tar.gz
nncmpp-6bd40f3ec174ce7bdbb327b7488dc6045e24a504.tar.xz
nncmpp-6bd40f3ec174ce7bdbb327b7488dc6045e24a504.zip
Fix potential issue with struct padding
The UI could very theoretically end up textless.
-rw-r--r--nncmpp.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/nncmpp.c b/nncmpp.c
index 9acb518..6647bca 100644
--- a/nncmpp.c
+++ b/nncmpp.c
@@ -5555,7 +5555,7 @@ tui_make_label (chtype attrs, const char *label)
struct widget *w = xcalloc (1, sizeof *w + len + 1);
w->on_render = tui_render_label;
w->attrs = attrs;
- memcpy (w + 1, label, len);
+ memcpy (w->text, label, len);
struct row_buffer buf = row_buffer_make ();
row_buffer_append (&buf, w->text, w->attrs);
@@ -6228,7 +6228,7 @@ x11_make_label (chtype attrs, const char *label)
struct widget *w = xcalloc (1, sizeof *w + normalized_len);
w->on_render = x11_render_label;
w->attrs = attrs;
- memcpy (w + 1, normalized, normalized_len);
+ memcpy (w->text, normalized, normalized_len);
free (normalized);
struct x11_font *font = x11_widget_font (w);