Skip to content

Commit 1bc4240

Browse files
Merge branch 'master' into test-context
2 parents f56c4b5 + b3a1134 commit 1bc4240

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/fread.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -927,10 +927,13 @@ static void parse_double_hexadecimal(FieldParseContext *ctx)
927927
if (neg) ch++;
928928
else if (*ch == '+') ch++;
929929

930-
const bool subnormal = ch[2] == '0';
930+
bool subnormal = false;
931931

932+
// Important!
933+
// Keep in mind that only ch[0] is guaranteed to be mapped.
934+
// Rearranging these checks (e.g. to make 'subnormal' const) will lead to segfaults in rare cases.
932935
if (ch[0] == '0' && (ch[1] == 'x' || ch[1] == 'X') &&
933-
(ch[2] == '1' || (subnormal)) && ch[3] == '.') {
936+
(ch[2] == '1' || (subnormal = (ch[2] == '0'))) && ch[3] == '.') {
934937
ch += 4;
935938
uint64_t acc = 0;
936939
uint8_t digit;

0 commit comments

Comments
 (0)