Skip to content

Commit 7c2a11e

Browse files
committed
FIX: disallow subtracting date from integer
fixes: Oldes/Rebol-issues#276
1 parent 8761cb6 commit 7c2a11e

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

src/core/t-date.c

+1
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,7 @@
746746

747747
if (type == REB_DATE) {
748748
if (action == A_SUBTRACT) {
749+
if(!IS_DATE(val)) Trap_Math_Args(REB_INTEGER, A_SUBTRACT);
749750
num = Diff_Date(date, VAL_DATE(arg));
750751
goto ret_int;
751752
}

src/tests/units/date-test.r3

+4
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ Rebol [
130130
--assert error? try [load "3-Jan-2010/10:00+2:00:56"]
131131
--assert error? try [load "3-Jan-2010/10:00+2:00:56.1234pm"]
132132

133+
--test-- "issue-276"
134+
;@@ https://github.com/Oldes/Rebol-issues/issues/276
135+
--assert error? try [0 - 1-jan-0000] ;- no crash!
136+
133137
===end-group===
134138

135139
===start-group=== "DATE/TIMEZONE"

0 commit comments

Comments
 (0)