]> git.ipfire.org Git - thirdparty/mlmmj.git/commitdiff
subscribtion cookie: properly remove the cookie
authorBaptiste Daroussin <bapt@FreeBSD.org>
Thu, 9 Mar 2023 08:25:28 +0000 (09:25 +0100)
committerBaptiste Daroussin <bapt@FreeBSD.org>
Thu, 9 Mar 2023 08:25:28 +0000 (09:25 +0100)
src/subscriberfuncs.c

index 583aaf152d952d36df34697b5f77560e0bb44373..2459eb0906d55df260cfc0ac296fc0a3d6895584 100644 (file)
@@ -155,16 +155,19 @@ get_subcookie_content(int listfd, bool unsub, const char *param)
                return (NULL);
        }
        fd = openat(dfd, param, O_RDONLY);
-       close(dfd);
-       if (fd == -1)
+       if (fd == -1) {
+               close(dfd);
                return (NULL);
+       }
        f = fdopen(fd, "r");
        if (getline(&line, &linecap, f) > 0) {
                chomp(line);
                fclose(f);
                unlinkat(dfd, param, 0);
+               close(dfd);
                return (line);
        }
+       close(dfd);
        fclose(f);
 
        return (NULL);