From: Brendan Hansen Date: Mon, 11 Dec 2023 02:47:32 +0000 (-0600) Subject: fixed: segmentation fault on windows X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=706ce7a6da0f302b56ebbef65f437c66291d738d;p=onyx.git fixed: segmentation fault on windows --- diff --git a/core/os/dir.onyx b/core/os/dir.onyx index 2cd83ed3..697ae315 100644 --- a/core/os/dir.onyx +++ b/core/os/dir.onyx @@ -61,7 +61,10 @@ list_directory :: (path: str) -> Iterator(DirectoryEntry) { } close :: (use c: &Context) { - dir_close(dir); + if opened { + dir_close(dir); + } + cfree(c); } diff --git a/runtime/src/ort_directories.h b/runtime/src/ort_directories.h index a2285246..80c0f261 100644 --- a/runtime/src/ort_directories.h +++ b/runtime/src/ort_directories.h @@ -111,6 +111,7 @@ ONYX_DEF(__dir_read, (WASM_I64, WASM_I32), (WASM_I32)) { ONYX_DEF(__dir_close, (WASM_I64), ()) { #ifdef _BH_WINDOWS Windows_Directory_Opened* dir = (Windows_Directory_Opened *) params->data[0].of.i64; + if (dir == NULL) return NULL; FindClose(dir->hndl); free(dir);