From decb4236bdd89630ffd03b63cf15c9d1b24d63e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=9A=93?= Date: Mon, 17 Feb 2025 00:07:54 -0500 Subject: [PATCH] Fix use after free in wasi.cpp found by AddressSanitizer --- binding-sandbox/wasi.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/binding-sandbox/wasi.cpp b/binding-sandbox/wasi.cpp index 7a61a932..083da5fd 100644 --- a/binding-sandbox/wasi.cpp +++ b/binding-sandbox/wasi.cpp @@ -109,9 +109,8 @@ wasi_zip_container::wasi_zip_container(const void *buffer, zip_uint64_t length, wasi_zip_container::~wasi_zip_container() { if (zip != NULL) { zip_close(zip); - if (source != NULL) { - zip_source_close(source); - } + } else if (source != NULL) { + zip_source_close(source); } }