mirror of
https://github.com/amitwh/markdown-converter.git
synced 2026-08-24 07:20:16 +05:30
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:
@@ -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++) {
|
||||
|
||||
Reference in New Issue
Block a user