| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent cc3e427 commit a9d9fdb
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -357,11 +357,20 @@ void uvwasi_fd_table_free(uvwasi_t* uvwasi, struct uvwasi_fd_table_t* table) { | |||
| 357 | 357 | uvwasi__free(uvwasi, entry); | |
| 358 | 358 | } | |
| 359 | 359 | ||
| 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 | + } | ||
| 365 | 374 | } | |
| 366 | 375 | ||
| 367 | 376 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments