]> git.alsa-project.org Git - alsa-tools.git/commitdiff
envy24control: fix file descriptor leaks in profiles
authorAndreas Persson <andreasp56@outlook.com>
Sat, 29 Mar 2025 07:37:01 +0000 (08:37 +0100)
committerJaroslav Kysela <perex@perex.cz>
Wed, 9 Apr 2025 09:44:11 +0000 (11:44 +0200)
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 <andreasp56@outlook.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
envy24control/profiles.c

index 6dbe7d17b5d6666bec6aac0528947dc52bb5be49..a67ef0c6a6cc7e2f6cb9b4431917c4d11caf875f 100644 (file)
@@ -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)) {