mirror of
https://github.com/penpot/penpot.git
synced 2026-04-25 11:18:36 +00:00
🐛 Fix infinite recursion in get-frame-ids for thumbnail extraction (#8807)
The get-frame-ids function could enter infinite recursion when: 1. There's a circular reference in the frame hierarchy 2. A shape's frame-id points to itself (corrupt data) The fix uses the cached version (get-frame-ids-cached) in recursive calls and adds a guard to prevent self-referencing.
This commit is contained in:
parent
52f28a1eee
commit
e10bd6a8d3
@ -228,25 +228,25 @@
|
||||
instance-root?
|
||||
(conj ["component" id]))]
|
||||
|
||||
(swap! frame-id-cache assoc id {:status :in-progress
|
||||
:result local-result})
|
||||
(swap! frame-id-cache assoc id local-result)
|
||||
|
||||
(let [result
|
||||
(cond-> local-result
|
||||
(and (uuid? (:frame-id old-shape))
|
||||
(not= uuid/zero (:frame-id old-shape)))
|
||||
(not= uuid/zero (:frame-id old-shape))
|
||||
(not= id (:frame-id old-shape)))
|
||||
(into (get-frame-ids-cached (:frame-id old-shape)))
|
||||
|
||||
(and (uuid? (:frame-id new-shape))
|
||||
(not= uuid/zero (:frame-id new-shape)))
|
||||
(not= uuid/zero (:frame-id new-shape))
|
||||
(not= id (:frame-id new-shape)))
|
||||
(into (get-frame-ids-cached (:frame-id new-shape))))]
|
||||
(swap! frame-id-cache assoc id {:status :done
|
||||
:result result})
|
||||
(swap! frame-id-cache assoc id result)
|
||||
result)))
|
||||
|
||||
(get-frame-ids-cached [id]
|
||||
(if-let [cached (get @frame-id-cache id)]
|
||||
(:result cached)
|
||||
(if (contains? @frame-id-cache id)
|
||||
(get @frame-id-cache id)
|
||||
(get-frame-ids id)))]
|
||||
(into #{}
|
||||
(comp (mapcat extract-ids)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user