From: Andreas Persson Date: Sat, 29 Mar 2025 07:37:01 +0000 (+0100) Subject: envy24control: fix file descriptor leaks in profiles X-Git-Tag: v1.2.14~5 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=52e64810471910354d04527ee679688709db313b;p=alsa-tools.git 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 --- 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)) {