Skip to content

Commit a75d42e

Browse files
committed
gh-124621: Emscripten: Fix regression in use-after-close error handling
Introduced in GH-136822. If the fd is already closed, `SYSCALLS.getStreamFromFD()` throws an error. We need to catch it and discard it. The `__wasi_fd_read_orig()` fallback will use it to set errno.
1 parent 7ae4749 commit a75d42e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Python/emscripten_syscalls.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,16 @@ EM_JS_MACROS(__externref_t, __maybe_fd_read_async, (
148148
size_t iovcnt,
149149
__wasi_size_t *nread
150150
), {
151-
var stream = SYSCALLS.getStreamFromFD(fd);
152151
if (!WebAssembly.promising) {
153152
return null;
154153
}
154+
var stream;
155+
try {
156+
stream = SYSCALLS.getStreamFromFD(fd);
157+
} catch (e) {
158+
// We'll let fd_read_orig() handle setting errno.
159+
return null;
160+
}
155161
if (!stream.stream_ops.readAsync) {
156162
// Not an async device. Fall back to __wasi_fd_read_orig().
157163
return null;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy