From 69b1707d82b498eb88a097c72595a848c3e0007f Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 23 Feb 2023 13:00:06 -0700 Subject: [PATCH] [wasm] Return empty object when ref2obj fails --- src/hb-wasm-api-face.hh | 2 -- src/hb-wasm-api-font.hh | 3 --- src/hb-wasm-api.hh | 2 +- 3 files changed, 1 insertion(+), 6 deletions(-) diff --git a/src/hb-wasm-api-face.hh b/src/hb-wasm-api-face.hh index 08e6671c8..f1495e75a 100644 --- a/src/hb-wasm-api-face.hh +++ b/src/hb-wasm-api-face.hh @@ -39,8 +39,6 @@ face_reference_table (HB_WASM_EXEC_ENV_COMPOUND HB_RETURN_TYPE (blob_t, blob); HB_REF2OBJ (face); - if (unlikely (!face)) - return; blob.length = 1; } diff --git a/src/hb-wasm-api-font.hh b/src/hb-wasm-api-font.hh index 788261bf6..9ac51a61b 100644 --- a/src/hb-wasm-api-font.hh +++ b/src/hb-wasm-api-font.hh @@ -36,8 +36,6 @@ font_get_face (HB_WASM_EXEC_ENV font_t fontref) { HB_REF2OBJ (font); - if (unlikely (!font)) - return nullref; hb_face_t *face = hb_font_get_face (font); @@ -46,7 +44,6 @@ font_get_face (HB_WASM_EXEC_ENV } - }} #endif /* HB_WASM_FONT_HH */ diff --git a/src/hb-wasm-api.hh b/src/hb-wasm-api.hh index 8f9c7d8ce..b245222f7 100644 --- a/src/hb-wasm-api.hh +++ b/src/hb-wasm-api.hh @@ -64,7 +64,7 @@ HB_INTERNAL extern hb_user_data_key_t _hb_wasm_ref_type_key; /* This works because all our objects have the same hb_object_t layout. */ \ if (unlikely (hb_##obj##_get_user_data (obj, &_hb_wasm_ref_type_key) != \ (void *) hb_wasm_ref_type_##obj)) \ - obj = nullptr; \ + obj = hb_##obj##_get_empty (); \ } HB_STMT_END #define HB_OBJ2REF(obj) \ uint32_t obj##ref = nullref; \