mirror of
https://github.com/storytold/photocraft.git
synced 2026-10-28 03:47:00 -06:00
layer.linkLayers picked the new link group as max(link_group) + 1, computed even when unlinking. A .pcraft or PSD can store u64::MAX, so the addition panicked in checked builds and wrapped to 0 in release, where it could merge the selection into an existing group 0. Add Document::unused_link_group: max + 1 when it fits, otherwise the smallest free id from 1, never wrapping. Link Layers uses it only when linking and returns an error if no id is left. Also read the first selected group and the member counts without indexing. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>