From fad330acd1ef2ffbf139ca1f52e93e3b367cf46f Mon Sep 17 00:00:00 2001 From: gingerBill Date: Mon, 6 Mar 2023 15:21:20 +0000 Subject: [PATCH] Fix bug with nil pointer --- core/strconv/strconv.odin | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/strconv/strconv.odin b/core/strconv/strconv.odin index 5c96f584c..dc3d7dbf1 100644 --- a/core/strconv/strconv.odin +++ b/core/strconv/strconv.odin @@ -559,10 +559,12 @@ parse_f32 :: proc(s: string, n: ^int = nil) -> (value: f32, ok: bool) { parse_f64 :: proc(str: string, n: ^int = nil) -> (value: f64, ok: bool) { - value, n^, ok = parse_f64_prefix(str) - if ok && len(str) != n^ { + nr: int + value, nr, ok = parse_f64_prefix(str) + if ok && len(str) != nr { ok = false } + if n != nil { n^ = nr } return } @@ -760,7 +762,6 @@ parse_f64_prefix :: proc(str: string) -> (value: f64, nr: int, ok: bool) { if mantissa != 0 { exp = decimal_point - nd_mant } - // TODO(bill): check underscore correctness ok = true return }