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: 20.11.0-rc1~32 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b74cfe0edd1dbfa064d0d7fc9429fde707dff50c;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 e629961606cf55aef9a32bdcf851df512303d3d3) --- 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);