Skip to content

Commit

Permalink
Merge pull request #15431 from alrvid/patch-1
Browse files Browse the repository at this point in the history
Handle negative values passed to close()
  • Loading branch information
0xc0170 authored Jul 3, 2023
2 parents 89c1705 + 56ca532 commit f9c0cd2
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions platform/source/mbed_retarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,10 @@ extern "C" int PREFIX(_close)(FILEHANDLE fh)
#if !MBED_CONF_PLATFORM_STDIO_MINIMAL_CONSOLE_ONLY
extern "C" int close(int fildes)
{
if (fildes < 0) {
errno = EBADF;
return -1;
}
FileHandle *fhc = mbed_file_handle(fildes);
filehandles[fildes] = NULL;
if (fhc == NULL) {
Expand Down

0 comments on commit f9c0cd2

Please sign in to comment.