mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-09 14:18:20 +00:00
fix(c-api) Call wasi_env_delete manually.
`wasi_get_imports` isn't taking ownership of `wasi_env_t` (despites what is written in the documentation). And it must not take ownership of it, since one could use it with the `wasi_env_read_stdout` & sibling functions after having called `wasi_get_imports`. Consequently, this patch calls `wasi_env_delete` to avoid leaking memory.
This commit is contained in:
@@ -143,6 +143,7 @@ int main(int argc, char* argv[]) {
|
||||
|
||||
#ifdef WASI
|
||||
bool get_imports_result = wasi_get_imports(store, module, wasi_env, &imports);
|
||||
wasi_env_delete(wasi_env);
|
||||
|
||||
if (!get_imports_result) {
|
||||
fprintf(stderr, "Error getting WASI imports!\n");
|
||||
|
||||
Reference in New Issue
Block a user