Skip to content

Commit 915b4d2

Browse files
authored
Fix few wasm-c-api python binding issues (#2029)
How to python language binding test cases: ``` $ cd <wamr_dir>/language-bindings/python $ python -m pip install -e . $ cd wasm-c-api $ python -m unittest tests/test_basic.py $ python -m unittest tests/test_advanced.py ```
1 parent 05d7ec3 commit 915b4d2

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

core/iwasm/common/wasm_c_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1905,7 +1905,7 @@ wasm_trap_new_internal(wasm_store_t *store,
19051905
}
19061906

19071907
/* fill in message */
1908-
if (strlen(error_info) > 0) {
1908+
if (error_info && strlen(error_info) > 0) {
19091909
if (!(trap->message = malloc_internal(sizeof(wasm_byte_vec_t)))) {
19101910
goto failed;
19111911
}

language-bindings/python/wasm-c-api/tests/test_basic.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,9 +1183,10 @@ def test_wasm_instance_new_pos_empty_imports(self):
11831183
self._wasm_store, module, imports, create_null_pointer(wasm_trap_t)
11841184
)
11851185

1186-
wasm_instance_delete(instance)
11871186
wasm_module_delete(module)
11881187

1188+
self.assertIsNullPointer(instance)
1189+
11891190
def test_wasm_instance_new_pos(self):
11901191
binary = load_module_file(MODULE_BINARY)
11911192
module = wasm_module_new(self._wasm_store, binary)
@@ -1227,9 +1228,10 @@ def test_wasm_instance_new_neg_null_imports(self):
12271228
create_null_pointer(wasm_trap_t),
12281229
)
12291230

1230-
wasm_instance_delete(instance)
12311231
wasm_module_delete(module)
12321232

1233+
self.assertIsNullPointer(instance)
1234+
12331235
# test those APIs in advanced:
12341236
# wasm_instance_delete
12351237
# wasm_instance_exports

0 commit comments

Comments
 (0)