Skip to content

Commit a988506

Browse files
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
1 parent adfc184 commit a988506

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

main/astfd.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,8 @@ int __ast_fdleak_fclose(FILE *ptr)
280280
{
281281
int fd, res;
282282
if (!ptr) {
283-
return fclose(ptr);
283+
errno = EINVAL;
284+
return -1;
284285
}
285286

286287
fd = fileno(ptr);

0 commit comments

Comments
 (0)