diff --git a/src/hb-wasm-api-buffer.hh b/src/hb-wasm-api-buffer.hh index 64217a041..3cf793850 100644 --- a/src/hb-wasm-api-buffer.hh +++ b/src/hb-wasm-api-buffer.hh @@ -164,11 +164,13 @@ HB_WASM_API (bool_t, buffer_set_contents) (HB_WASM_EXEC_ENV if (unlikely (hb_unsigned_mul_overflows (length, sizeof (buffer->info[0]), &bytes))) return false; - if (unlikely (!buffer->resize (length))) - return false; - glyph_info_t *info = (glyph_info_t *) (validate_app_addr (contents->info, bytes) ? addr_app_to_native (contents->info) : nullptr); glyph_position_t *pos = (glyph_position_t *) (validate_app_addr (contents->pos, bytes) ? addr_app_to_native (contents->pos) : nullptr); + if (unlikely (!info || !pos)) + return false; + + if (unlikely (!buffer->resize (length))) + return false; if (!buffer->have_positions) buffer->clear_positions (); /* This is wasteful. */ diff --git a/src/hb-wasm-api-face.hh b/src/hb-wasm-api-face.hh index 22e50e944..e48a1d761 100644 --- a/src/hb-wasm-api-face.hh +++ b/src/hb-wasm-api-face.hh @@ -36,8 +36,15 @@ HB_WASM_API (ptr_t(face_t), face_create) (HB_WASM_EXEC_ENV unsigned int index) { HB_PTR_PARAM (blob_t, blob); + if (unlikely (!blob)) + return nullref; + + char *data = HB_ARRAY_APP2NATIVE (char, blob->data, blob->length); + if (unlikely (!data)) + return nullref; + hb_blob_t *hb_blob = hb_blob_create( - HB_ARRAY_APP2NATIVE (char, blob->data, blob->length), + data, blob->length, HB_MEMORY_MODE_DUPLICATE, NULL, diff --git a/src/hb-wasm-api-font.hh b/src/hb-wasm-api-font.hh index 8dbeda0bb..2767ea3da 100644 --- a/src/hb-wasm-api-font.hh +++ b/src/hb-wasm-api-font.hh @@ -256,6 +256,9 @@ HB_WASM_API (bool_t, font_set_coords) (HB_WASM_EXEC_ENV return false; const int *our_coords = (const int *) (validate_app_addr (coords->coords, bytes) ? addr_app_to_native (coords->coords) : nullptr); + if (unlikely (!our_coords)) + return false; + hb_font_set_var_coords_normalized(font, our_coords, length); return true; }