From 52e64810471910354d04527ee679688709db313b Mon Sep 17 00:00:00 2001 From: Andreas Persson Date: Sat, 29 Mar 2025 08:37:01 +0100 Subject: [PATCH] envy24control: fix file descriptor leaks in profiles File descriptors were leaked when "Save active profile" was pressed. Add the missing calls to close. Closes: https://github.com/alsa-project/alsa-tools/pull/33 Signed-off-by: Andreas Persson Signed-off-by: Jaroslav Kysela --- envy24control/profiles.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/envy24control/profiles.c b/envy24control/profiles.c index 6dbe7d1..a67ef0c 100644 --- a/envy24control/profiles.c +++ b/envy24control/profiles.c @@ -1146,13 +1146,16 @@ int save_restore(const char * const operation, const int profile_number, const i fprintf(stderr, "Cannot save settings for card '%d' in profile '%d'.\n", card_number, profile_number); return -errno; } + close(res); unlink(cfgfile); } else { + close(res); if ((res = open(cfgfile, O_RDWR | 0400000 /* O_NOFOLLOW */, FILE_CREA_MODE)) < 0) { fprintf(stderr, "Cannot open configuration file '%s' for writing.\n", cfgfile); fprintf(stderr, "Cannot save settings for card '%d' in profile '%d'.\n", card_number, profile_number); return -errno; } + close(res); } res = save_profile(profile_number, card_number, profile_name, cfgfile); } else if (!strcmp(operation, ALSACTL_OP_RESTORE)) { -- 2.47.1