[backport 1.25] Add bounds checking for clipspace indices to prevent paste errors (core/1.25 backport) (#4904)

This commit is contained in:
Christian Byrne
2025-08-10 20:57:12 -07:00
committed by GitHub
parent 980e3ebfab
commit d1434d1c80
2 changed files with 21 additions and 8 deletions

View File

@@ -3976,13 +3976,19 @@ class UIManager {
const mainImageFilename = const mainImageFilename =
new URL(mainImageUrl).searchParams.get('filename') ?? undefined new URL(mainImageUrl).searchParams.get('filename') ?? undefined
const combinedImageFilename = let combinedImageFilename: string | null | undefined
if (
ComfyApp.clipspace?.combinedIndex !== undefined && ComfyApp.clipspace?.combinedIndex !== undefined &&
ComfyApp.clipspace?.imgs?.[ComfyApp.clipspace.combinedIndex]?.src ComfyApp.clipspace?.imgs &&
? new URL( ComfyApp.clipspace.combinedIndex < ComfyApp.clipspace.imgs.length &&
ComfyApp.clipspace.imgs[ComfyApp.clipspace.combinedIndex].src ComfyApp.clipspace.imgs[ComfyApp.clipspace.combinedIndex]?.src
).searchParams.get('filename') ) {
: undefined combinedImageFilename = new URL(
ComfyApp.clipspace.imgs[ComfyApp.clipspace.combinedIndex].src
).searchParams.get('filename')
} else {
combinedImageFilename = undefined
}
const imageLayerFilenames = const imageLayerFilenames =
mainImageFilename !== undefined mainImageFilename !== undefined

View File

@@ -385,8 +385,15 @@ export class ComfyApp {
static pasteFromClipspace(node: LGraphNode) { static pasteFromClipspace(node: LGraphNode) {
if (ComfyApp.clipspace) { if (ComfyApp.clipspace) {
// image paste // image paste
const combinedImgSrc = let combinedImgSrc: string | undefined
ComfyApp.clipspace.imgs?.[ComfyApp.clipspace.combinedIndex].src if (
ComfyApp.clipspace.combinedIndex !== undefined &&
ComfyApp.clipspace.imgs &&
ComfyApp.clipspace.combinedIndex < ComfyApp.clipspace.imgs.length
) {
combinedImgSrc =
ComfyApp.clipspace.imgs[ComfyApp.clipspace.combinedIndex].src
}
if (ComfyApp.clipspace.imgs && node.imgs) { if (ComfyApp.clipspace.imgs && node.imgs) {
if (node.images && ComfyApp.clipspace.images) { if (node.images && ComfyApp.clipspace.images) {
if (ComfyApp.clipspace['img_paste_mode'] == 'selected') { if (ComfyApp.clipspace['img_paste_mode'] == 'selected') {