From 5f547fb1183a6ef61f3554b0b1e04e38c6871f26 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Tue, 30 Jan 2018 15:16:56 -0800 Subject: [PATCH] GUACAMOLE-313: Ensure keydef structure is freed in all cases. --- src/guaclog/state.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/guaclog/state.c b/src/guaclog/state.c index 5e187087..b33bdd76 100644 --- a/src/guaclog/state.c +++ b/src/guaclog/state.c @@ -219,14 +219,19 @@ int guaclog_state_update_key(guaclog_state* state, int keysym, bool pressed) { /* Update tracked key state for modifiers */ if (keydef->modifier) { + + /* Keydef will be automatically freed if successfully added to state */ if (guaclog_state_add_key(state, keydef, pressed)) guaclog_keydef_free(keydef); else guaclog_state_trim_keys(state); + + return 0; + } /* Output key states only for printable keys */ - else if (pressed) { + if (pressed) { if (guaclog_state_is_shortcut(state)) { @@ -260,6 +265,7 @@ int guaclog_state_update_key(guaclog_state* state, int keysym, bool pressed) { } + guaclog_keydef_free(keydef); return 0; }