From c01806d6fad21c195b632ad19dbcaffa0309d783 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Tue, 1 Jan 2019 20:31:00 +0100 Subject: [PATCH] module/xkb: declare and initialize 'symbols' before first goto err This ensures we don't free() an invalid value. --- modules/xkb.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/xkb.c b/modules/xkb.c index 55ce5df..0396387 100644 --- a/modules/xkb.c +++ b/modules/xkb.c @@ -143,6 +143,8 @@ get_layouts(xcb_connection_t *conn) for (ssize_t i = 0; i < ret.count; i++) group_name_cookies[i] = xcb_get_atom_name(conn, vlist.groups[i]); + char *symbols = NULL; + /* Get layout short names (e.g. "us") */ xcb_get_atom_name_reply_t *atom_name = xcb_get_atom_name_reply( conn, symbols_name_cookie, &err); @@ -152,8 +154,8 @@ get_layouts(xcb_connection_t *conn) goto err; } - char *symbols = strndup(xcb_get_atom_name_name(atom_name), - xcb_get_atom_name_name_length(atom_name)); + symbols = strndup(xcb_get_atom_name_name(atom_name), + xcb_get_atom_name_name_length(atom_name)); free(atom_name); /* Get layout long names (e.g. "English (US)") */