Skip to content

Commit

Permalink
fix: prevent infinite loop if step is two or more zeros
Browse files Browse the repository at this point in the history
  • Loading branch information
sheerlox committed Oct 23, 2023
1 parent e284edc commit ab39ad4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/time.ts
Original file line number Diff line number Diff line change
Expand Up @@ -774,10 +774,10 @@ export class CronTime {
let upper = mUpper !== undefined ? parseInt(mUpper, 10) : undefined;

const wasStepDefined = mStep !== undefined;
if (mStep === '0') {
const step = parseInt(mStep ?? '1', 10);
if (step === 0) {
throw new Error(`Field (${unit}) has a step of zero`);
}
const step = parseInt(mStep ?? '1', 10);

if (upper !== undefined && lower > upper) {
throw new Error(`Field (${unit}) has an invalid range`);
Expand Down

0 comments on commit ab39ad4

Please sign in to comment.