From 74a2f338c67a8c3cd5220b19366f0331332dd69d Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 2 Mar 2023 10:29:01 -0700 Subject: [PATCH] [wasm-shape] Don't crash if font is bad --- src/hb-wasm-shape.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/hb-wasm-shape.cc b/src/hb-wasm-shape.cc index 30c0d193f..7d584c13e 100644 --- a/src/hb-wasm-shape.cc +++ b/src/hb-wasm-shape.cc @@ -425,6 +425,11 @@ retry: { DEBUG_MSG (WASM, module_inst, "Calling shape() failed: %s", wasm_runtime_get_exception (module_inst)); + if (!buffer->ensure_unicode ()) + { + DEBUG_MSG (WASM, font, "Shape failed but buffer is not in Unicode; failing..."); + goto fail; + } if (retried) { DEBUG_MSG (WASM, font, "Giving up...");