]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
astfd.c: Avoid calling fclose with NULL argument.
authorNaveen Albert <asterisk@phreaknet.org>
Tue, 24 Sep 2024 11:29:59 +0000 (07:29 -0400)
committerNaveen Albert <asterisk@phreaknet.org>
Wed, 25 Sep 2024 18:27:17 +0000 (18:27 +0000)
Don't pass through a NULL argument to fclose, which is undefined
behavior, and instead return -1 and set errno appropriately. This
also avoids a compiler warning with glibc 2.38 and newer, as glibc
commit 71d9e0fe766a3c22a730995b9d024960970670af
added the nonnull attribute to this argument.

Resolves: #900

main/astfd.c

index 78efe116ae3d9e990c444a2fe0056eabe9ecc734..3dc62faff398b075f7491dac717b35157bf178a0 100644 (file)
@@ -280,7 +280,8 @@ int __ast_fdleak_fclose(FILE *ptr)
 {
        int fd, res;
        if (!ptr) {
-               return fclose(ptr);
+               errno = EINVAL;
+               return -1;
        }
 
        fd = fileno(ptr);