From 7b1c5e86aea4babcecb572a9b69f04cf95f5d102 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sat, 25 Feb 2023 14:18:09 -0700 Subject: [PATCH] [wasm-shape] Minor conditionalize allocation --- src/hb-wasm-shape.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/hb-wasm-shape.cc b/src/hb-wasm-shape.cc index 7970e4c5d..adf24b9a6 100644 --- a/src/hb-wasm-shape.cc +++ b/src/hb-wasm-shape.cc @@ -336,9 +336,9 @@ retry: arguments[2].kind = WASM_I32; arguments[2].of.i32 = bufferref; arguments[3].kind = WASM_I32; - arguments[3].of.i32 = wasm_runtime_module_dup_data (module_inst, - (const char *) features, - num_features * sizeof (features[0])); + arguments[3].of.i32 = num_features ? wasm_runtime_module_dup_data (module_inst, + (const char *) features, + num_features * sizeof (features[0])) : 0; arguments[4].kind = WASM_I32; arguments[4].of.i32 = num_features; @@ -346,7 +346,8 @@ retry: ARRAY_LENGTH (results), results, ARRAY_LENGTH (arguments), arguments); - wasm_runtime_module_free (module_inst, arguments[2].of.i32); + if (num_features) + wasm_runtime_module_free (module_inst, arguments[2].of.i32); if (unlikely (!ret || !results[0].of.i32)) {