🐛 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:
Andrey Antukh 2026-04-07 16:34:08 +02:00 committed by GitHub
parent 52f28a1eee
commit e10bd6a8d3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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)