[wasm-api-shape] Avoid a couple of crashes
diff --git a/src/hb-wasm-api-shape.hh b/src/hb-wasm-api-shape.hh
index 7e12969..622ff05 100644
--- a/src/hb-wasm-api-shape.hh
+++ b/src/hb-wasm-api-shape.hh
@@ -46,6 +46,14 @@
HB_REF2OBJ (font);
HB_REF2OBJ (buffer);
+ /* Pre-conditions that make hb_shape_full() crash should be checked here. */
+
+ if (unlikely (!buffer->ensure_unicode ()))
+ return false;
+
+ if (unlikely (!HB_DIRECTION_IS_VALID (buffer->props.direction)))
+ return false;
+
HB_ARRAY_PARAM (const feature_t, features, num_features);
if (unlikely (!features && num_features))
return false;