Skip to content

Commit

Permalink
astfd.c: Avoid calling fclose with NULL argument.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
InterLinked1 authored and asterisk-org-access-app[bot] committed Sep 25, 2024
1 parent adfc184 commit a988506
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion main/astfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit a988506

Please sign in to comment.