From 4edfd85286447d4c4e62d74a8c8f75314d8a8321 Mon Sep 17 00:00:00 2001 From: zengwei2000 <102871671+zengwei2000@users.noreply.github.com> Date: Wed, 20 Dec 2023 23:37:28 +0800 Subject: [PATCH] wasm: fix the memory leak: wasm_buf wasm: fix the memory leak: wasm_buf Signed-off-by: zengwei zengwei1@uniontech.com --- examples/wasm/iwasmt.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/wasm/iwasmt.c b/examples/wasm/iwasmt.c index 6bb488b088..d3fadd1afd 100644 --- a/examples/wasm/iwasmt.c +++ b/examples/wasm/iwasmt.c @@ -122,6 +122,7 @@ int wamr_run_cp(const void *bytecode, size_t bytecode_len, int argc, char *argv[ if (argc > 0) { parv = malloc(sizeof(argv[0]) * argc); if (!parv){ + free(wasm_buf); return -1; } memcpy(parv, argv, sizeof(argv[0]) * argc); @@ -130,6 +131,7 @@ int wamr_run_cp(const void *bytecode, size_t bytecode_len, int argc, char *argv[ argc = 1; parv = malloc(sizeof(argv[0]) * argc); if (!parv) { + free(wasm_buf); return -1; } parv[0] = empty;