Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a9d9fdb

Browse filesBrowse files
cjihrigtargos
authored andcommitted
deps: uvwasi: cherry-pick 64e59d5
Original commit message: This commit ensures that multiple calls to uvwasi_destroy() are possible. Prior to this commit, subsequent calls to destroy() would abort because the file table's rwlock was incorrectly being destroyed multiple times. PR-URL: #31076 Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent cc3e427 commit a9d9fdb
Copy full SHA for a9d9fdb

File tree

Expand file treeCollapse file tree

1 file changed

+14
-5
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+14
-5
lines changed
Open diff view settings
Collapse file

‎deps/uvwasi/src/fd_table.c‎

Copy file name to clipboardExpand all lines: deps/uvwasi/src/fd_table.c
+14-5Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -357,11 +357,20 @@ void uvwasi_fd_table_free(uvwasi_t* uvwasi, struct uvwasi_fd_table_t* table) {
357357
uvwasi__free(uvwasi, entry);
358358
}
359359

360-
uvwasi__free(uvwasi, table->fds);
361-
table->fds = NULL;
362-
table->size = 0;
363-
table->used = 0;
364-
uv_rwlock_destroy(&table->rwlock);
360+
if (table->fds != NULL) {
361+
/* It's fine to call uvwasi__free() multiple times on table->fds. However,
362+
it is not fine to call uv_rwlock_destroy() multiple times. Guard against
363+
that by ensuring that table->fds is not NULL. Technically, it's possible
364+
that uvwasi_fd_table_init() initialized the rwlock successfully, but
365+
failed to initialize fds. However, the only way that's possible is if
366+
the application already ran out of memory.
367+
*/
368+
uvwasi__free(uvwasi, table->fds);
369+
table->fds = NULL;
370+
table->size = 0;
371+
table->used = 0;
372+
uv_rwlock_destroy(&table->rwlock);
373+
}
365374
}
366375

367376

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.