Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iwasm: fix native lib cleanup after error #2443

Merged
merged 3 commits into from
Aug 14, 2023

Conversation

yamt
Copy link
Collaborator

@yamt yamt commented Aug 10, 2023

  • if something failed after calling init_native_lib, call deinit_native_lib to clean up.

  • restructure the relevant code for better maintainability.

* if something failed after calling init_native_lib,
  call deinit_native_lib to clean up.

* restructure the relevant code for better maintainability.
struct native_lib *
load_native_lib(const char *name)
{
struct native_lib *lib = malloc(sizeof(*lib));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about using wasm_runtime_malloc/wasm_runtime_free to be consistent with other places?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it makes sense. i will change.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}
free(lib);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should use wasm_runtime_free.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops. fixed. thank you.

@wenyongh wenyongh merged commit 5780eff into bytecodealliance:main Aug 14, 2023
368 checks passed
victoryang00 pushed a commit to victoryang00/wamr-aot-gc-checkpoint-restore that referenced this pull request May 27, 2024
- If something failed after calling init_native_lib, call deinit_native_lib to clean up.
- Restructure the relevant code for better maintainability.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants