File tree 2 files changed +12
-7
lines changed
2 files changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -334,7 +334,7 @@ bad_hex: Trap0(RE_INVALID_CHARS);
334
334
REBINT num = (REBINT )len ;
335
335
REBYTE buf [MAX_NUM_LEN + 4 ];
336
336
REBYTE * bp ;
337
- REBI64 n ;
337
+ REBI64 n = 0 ;
338
338
REBOOL neg = FALSE;
339
339
340
340
// Super-fast conversion of zero and one (most common cases):
@@ -369,12 +369,13 @@ bad_hex: Trap0(RE_INVALID_CHARS);
369
369
len = (REBCNT )(bp - & buf [0 ]);
370
370
if (neg ) len -- ;
371
371
if (len > 19 ) return 0 ;
372
-
373
- // Convert, check, and return:
374
- errno = 0 ;
375
- n = CHR_TO_INT (buf );
376
- if (errno != 0 ) return 0 ; //overflow
377
- if ((n > 0 && neg ) || (n < 0 && !neg )) return 0 ;
372
+ if (len > 0 ) {
373
+ // Convert, check, and return:
374
+ errno = 0 ;
375
+ n = CHR_TO_INT (buf );
376
+ if (errno != 0 ) return 0 ; //overflow
377
+ if ((n > 0 && neg ) || (n < 0 && !neg )) return 0 ;
378
+ }
378
379
SET_INTEGER (value , n );
379
380
return cp ;
380
381
}
Original file line number Diff line number Diff line change @@ -99,6 +99,10 @@ Rebol [
99
99
--assert all [error? e: try [to integer! "9'223'372'036'854'775'808" ] e/id = 'bad-make-arg]
100
100
;@@ https://github.com/Oldes/Rebol-issues/issues/2099
101
101
--assert 302961000000 = to integer! "3.02961E+11"
102
+ ;@@ https://github.com/Oldes/Rebol-issues/issues/2504
103
+ --assert 0 = to integer! "0"
104
+ --assert 0 = to integer! "00"
105
+ --assert 0 = to integer! "00000000000"
102
106
103
107
===end-group===
104
108
You can’t perform that action at this time.
0 commit comments