From: Naveen Albert Date: Tue, 24 Sep 2024 11:29:59 +0000 (-0400) Subject: astfd.c: Avoid calling fclose with NULL argument. X-Git-Tag: 21.6.0-rc1~31 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=10963cd27e4ba1db7b539085f39c8ebbc984bf38;p=thirdparty%2Fasterisk.git astfd.c: Avoid calling fclose with NULL argument. 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 (cherry picked from commit 7c982de5c6f56271b8866fd9ecc38d6b2975e986) --- diff --git a/main/astfd.c b/main/astfd.c index 78efe116ae..3dc62faff3 100644 --- a/main/astfd.c +++ b/main/astfd.c @@ -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);