fix(pdf): guard pdfSplit against non-positive interval infinite loop

The interval split mode looped for (i = 0; i < totalPages; i += interval),
which spins forever when interval <= 0. Both the single-file dialog and the
batch dialog can reach it (the batch dialog's validateOperationData only
checks truthiness, so -1 passes). Guard at the source in the main process:
reject non-positive or non-integer intervals before the loop, protecting
both paths and any future caller.

Amit Haridas
This commit is contained in:
2026-08-23 19:31:33 +05:30
parent 2e16868f59
commit 363de75375
2 changed files with 54 additions and 0 deletions
+3
View File
@@ -112,6 +112,9 @@ async function pdfSplit(data) {
}
} else if (data.splitMode === 'interval') {
const interval = data.interval;
if (!Number.isInteger(interval) || interval <= 0) {
return { success: false, message: 'Split interval must be a positive integer.' };
}
for (let i = 0; i < totalPages; i += interval) {
const pages = [];
for (let j = i; j < i + interval && j < totalPages; j++) {