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:
Ivan Enderlin
2021-02-02 13:49:41 +01:00
parent dd5196ef27
commit 453ece6415
4 changed files with 4 additions and 0 deletions

View File

@@ -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");