GUACAMOLE-313: Ensure keydef structure is freed in all cases.

This commit is contained in:
Michael Jumper 2018-01-30 15:16:56 -08:00
parent 5f5b4ea8eb
commit 5f547fb118

View File

@ -219,14 +219,19 @@ int guaclog_state_update_key(guaclog_state* state, int keysym, bool pressed) {
/* Update tracked key state for modifiers */ /* Update tracked key state for modifiers */
if (keydef->modifier) { if (keydef->modifier) {
/* Keydef will be automatically freed if successfully added to state */
if (guaclog_state_add_key(state, keydef, pressed)) if (guaclog_state_add_key(state, keydef, pressed))
guaclog_keydef_free(keydef); guaclog_keydef_free(keydef);
else else
guaclog_state_trim_keys(state); guaclog_state_trim_keys(state);
return 0;
} }
/* Output key states only for printable keys */ /* Output key states only for printable keys */
else if (pressed) { if (pressed) {
if (guaclog_state_is_shortcut(state)) { 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; return 0;
} }