Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/deps
diff options
context:
space:
mode:
authorcjihrig <cjihrig@gmail.com>2019-12-24 05:59:30 +0300
committercjihrig <cjihrig@gmail.com>2019-12-26 06:27:11 +0300
commita512bf28cf669f25545d90b6bbe2e5068460a8a5 (patch)
tree9b53c3085a58fa3b9997afe74cd91ae0f40884b2 /deps
parent3d500015feb4c8cc9a2ee9d18a6883acf0a3f5f2 (diff)
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: https://github.com/nodejs/node/pull/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>
Diffstat (limited to 'deps')
-rw-r--r--deps/uvwasi/src/fd_table.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/deps/uvwasi/src/fd_table.c b/deps/uvwasi/src/fd_table.c
index 0abddb5a21d..aad40e7407b 100644
--- a/deps/uvwasi/src/fd_table.c
+++ b/deps/uvwasi/src/fd_table.c
@@ -357,11 +357,20 @@ void uvwasi_fd_table_free(uvwasi_t* uvwasi, struct uvwasi_fd_table_t* table) {
uvwasi__free(uvwasi, entry);
}
- uvwasi__free(uvwasi, table->fds);
- table->fds = NULL;
- table->size = 0;
- table->used = 0;
- uv_rwlock_destroy(&table->rwlock);
+ if (table->fds != NULL) {
+ /* It's fine to call uvwasi__free() multiple times on table->fds. However,
+ it is not fine to call uv_rwlock_destroy() multiple times. Guard against
+ that by ensuring that table->fds is not NULL. Technically, it's possible
+ that uvwasi_fd_table_init() initialized the rwlock successfully, but
+ failed to initialize fds. However, the only way that's possible is if
+ the application already ran out of memory.
+ */
+ uvwasi__free(uvwasi, table->fds);
+ table->fds = NULL;
+ table->size = 0;
+ table->used = 0;
+ uv_rwlock_destroy(&table->rwlock);
+ }
}