🐛 Fix wasm crash in set_shape_fills (wasm) when fill list is empty

This commit is contained in:
Belén Albeza 2025-06-05 09:52:51 +02:00
parent ab0219876e
commit a30ab17605

View file

@ -8,7 +8,7 @@
"A WASM based render API" "A WASM based render API"
(:require (:require
["react-dom/server" :as rds] ["react-dom/server" :as rds]
[app.common.data :as d] [app.common.data :as d :refer [not-empty?]]
[app.common.data.macros :as dm] [app.common.data.macros :as dm]
[app.common.geom.matrix :as gmt] [app.common.geom.matrix :as gmt]
[app.common.geom.point :as gpt] [app.common.geom.point :as gpt]
@ -240,6 +240,7 @@
(defn set-shape-fills (defn set-shape-fills
[fills] [fills]
(when (not-empty? fills)
(let [fills (take types.fill/MAX-FILLS fills) (let [fills (take types.fill/MAX-FILLS fills)
image-fills (filter :fill-image fills) image-fills (filter :fill-image fills)
offset (mem/alloc-bytes (* (count fills) sr-fills/FILL-BYTE-SIZE)) offset (mem/alloc-bytes (* (count fills) sr-fills/FILL-BYTE-SIZE))
@ -269,7 +270,7 @@
(aget buffer 3))] (aget buffer 3))]
(when (zero? cached-image?) (when (zero? cached-image?)
(store-image id)))) (store-image id))))
image-fills))) image-fills))))
(defn set-shape-strokes (defn set-shape-strokes
[strokes] [strokes]