From abc7ac1029053f573b1b29b02b2a1fc7b0e583ec Mon Sep 17 00:00:00 2001 From: Benjamin Tissoires Date: Wed, 19 Aug 2015 11:31:58 -0400 Subject: [PATCH] tools: fix 2 valgrind complains When accessing the buttons of a profile, we should not unref it until we are done (or there will be some illegal access to a free-ed pointer). The last profile_unref should be called against the active_profile, not the last profile. Signed-off-by: Benjamin Tissoires --- tools/ratbag-command.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/ratbag-command.c b/tools/ratbag-command.c index 1f5bf719..68017c07 100644 --- a/tools/ratbag-command.c +++ b/tools/ratbag-command.c @@ -221,8 +221,6 @@ ratbag_cmd_info(struct ratbag *ratbag, uint32_t flags, int argc, char **argv) printf(" Resolution: %ddpi\n", dpi); printf(" Report rate: %dhz\n", rate); - ratbag_profile_unref(profile); - for (b = 0; b < num_buttons; b++) { enum ratbag_button_type type; @@ -231,8 +229,11 @@ ratbag_cmd_info(struct ratbag *ratbag, uint32_t flags, int argc, char **argv) printf("Button: %d type %s\n", b, button_type_to_str(type)); button = ratbag_button_unref(button); } + + profile = ratbag_profile_unref(profile); } - profile = ratbag_profile_unref(profile); + + active_profile = ratbag_profile_unref(active_profile); device = ratbag_device_unref(device); rc = 0;