mirror of
https://github.com/python/cpython.git
synced 2026-01-04 06:22:20 +00:00
gh-124621: Emscripten: Fix regression in use-after-close error handling (#136837)
This commit is contained in:
parent
69ea1b3a8f
commit
800d37feca
1 changed files with 8 additions and 1 deletions
|
|
@ -148,10 +148,17 @@ EM_JS_MACROS(__externref_t, __maybe_fd_read_async, (
|
|||
size_t iovcnt,
|
||||
__wasi_size_t *nread
|
||||
), {
|
||||
var stream = SYSCALLS.getStreamFromFD(fd);
|
||||
if (!WebAssembly.promising) {
|
||||
return null;
|
||||
}
|
||||
var stream;
|
||||
try {
|
||||
stream = SYSCALLS.getStreamFromFD(fd);
|
||||
} catch (e) {
|
||||
// If the fd was already closed or never existed, getStreamFromFD()
|
||||
// raises. We'll let fd_read_orig() handle setting errno.
|
||||
return null;
|
||||
}
|
||||
if (!stream.stream_ops.readAsync) {
|
||||
// Not an async device. Fall back to __wasi_fd_read_orig().
|
||||
return null;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue