Skip to content

Commit 800d37f

Browse files
authored
gh-124621: Emscripten: Fix regression in use-after-close error handling (#136837)
1 parent 69ea1b3 commit 800d37f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Python/emscripten_syscalls.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,17 @@ 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+
// If the fd was already closed or never existed, getStreamFromFD()
159+
// raises. We'll let fd_read_orig() handle setting errno.
160+
return null;
161+
}
155162
if (!stream.stream_ops.readAsync) {
156163
// Not an async device. Fall back to __wasi_fd_read_orig().
157164
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