Skip to content

Commit e65a5d3

Browse files
dblazeskivonovak
andauthored
fix(ios): remove potential division by zero minute interval (#997)
* fix: prevent division by zero crash in adjustMinimumDate when minuteInterval is 0 - Add safety check in adjustMinimumDate function to handle minuteInterval <= 0 - Return minimumDate unchanged when no valid interval is provided - Add debug logging to track minuteInterval values for troubleshooting - Fixes EXC_ARITHMETIC (EXC_I386_DIV) crash when modulo operation encounters zero divisor This fixes crashes that occur when DateTimePicker is used without explicitly setting minuteInterval, as the default value becomes 0 instead of the expected 1, causing division by zero in the modulo operation. * refactor: reduce logging in adjustMinimumDate Only log when minuteInterval <= 0 and we return date unchanged. Remove verbose logging for normal operation to reduce console noise. * Update RNDateTimePickerComponentView.mm * Update ios/fabric/RNDateTimePickerComponentView.mm --------- Co-authored-by: Vojtech Novak <[email protected]>
1 parent 535e554 commit e65a5d3

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

ios/fabric/RNDateTimePickerComponentView.mm

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
}
2323

2424
NSDate* adjustMinimumDate (NSDate* minimumDate, int minuteInterval) {
25+
// If minuteInterval is not set or invalid, return the date unchanged
26+
if (minuteInterval <= 0) {
27+
return minimumDate;
28+
}
29+
2530
NSInteger minute = [[NSCalendar currentCalendar] component:NSCalendarUnitMinute fromDate:minimumDate];
2631
NSInteger remainder = minute % minuteInterval;
2732
NSInteger adjustment = (remainder == 0) ? 0 : (minuteInterval - remainder);

0 commit comments

Comments
 (0)