Skip to content

Commit b24b1b4

Browse files
authored
[WasmFS] Fix asan.test_fs_js_api_wasmfs (#23898)
1 parent 7a6db39 commit b24b1b4

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

.circleci/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,7 @@ jobs:
537537
asan.test_asyncify_longjmp
538538
asan.test_pthread_run_on_main_thread
539539
asan.test_minimal_runtime_global_initializer
540+
asan.test_fs_js_api_wasmfs
540541
lsan.test_dylink_dso_needed
541542
lsan.test_stdio_locking
542543
lsan.test_dlfcn_basic

src/lib/libwasmfs.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,13 +195,12 @@ addToLibrary({
195195
} else {
196196
bytesRead = __wasmfs_read(stream.fd, dataBuffer, length);
197197
}
198-
bytesRead = FS.handleError(bytesRead);
199-
200-
for (var i = 0; i < length; i++) {
198+
for (var i = 0; i < bytesRead; i++) {
201199
buffer[offset + i] = {{{ makeGetValue('dataBuffer', 'i', 'i8')}}}
202200
}
203201

204202
_free(dataBuffer);
203+
bytesRead = FS.handleError(bytesRead);
205204
return bytesRead;
206205
},
207206
// Note that canOwn is an optimization that we ignore for now in WasmFS.
@@ -219,8 +218,8 @@ addToLibrary({
219218
} else {
220219
bytesRead = __wasmfs_write(stream.fd, dataBuffer, length);
221220
}
222-
bytesRead = FS.handleError(bytesRead);
223221
_free(dataBuffer);
222+
bytesRead = FS.handleError(bytesRead);
224223

225224
return bytesRead;
226225
},

0 commit comments

Comments
 (0)