AP_Filesystem: fixed open to return nullptr on failure

this impacts lua io.open()
This commit is contained in:
Andrew Tridgell 2022-11-10 08:37:54 +11:00
parent 7942b58fba
commit 5fc018fff4
1 changed files with 4 additions and 0 deletions

View File

@ -83,6 +83,10 @@ APFS_FILE *apfs_fopen(const char *pathname, const char *mode)
return nullptr;
}
f->fd = AP::FS().open(pathname, posix_fopen_modes_to_open(mode));
if (f->fd == -1) {
delete f;
return nullptr;
}
f->unget = -1;
return f;
}