aboutsummaryrefslogtreecommitdiff
path: root/src/time/format.go
diff options
context:
space:
mode:
authorJoe Tsai <joetsai@digital-static.net>2022-08-21 02:21:49 -0700
committerGopher Robot <gobot@golang.org>2022-08-23 17:35:01 +0000
commitf9cdc09497af299ef6a4d4d745aa0df4ebfdce52 (patch)
tree8ed63d9e11b49de8427396a28d0a48c506b13694 /src/time/format.go
parent4e9183cb14bf58011389c8a8c8ccaecd3ef50451 (diff)
downloadgo-f9cdc09497af299ef6a4d4d745aa0df4ebfdce52.tar.xz
time: fix Parse for empty seconds
The error return value of the seconds field is overwritten and not checked in the presence of a fractional second. Perform an explicit check for errors. Fixes #54569 Change-Id: I1204c8bdcd5a5a09b773d9e44748141ed1e5cb20 Reviewed-on: https://go-review.googlesource.com/c/go/+/425036 Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com> Run-TryBot: Joseph Tsai <joetsai@digital-static.net> Auto-Submit: Joseph Tsai <joetsai@digital-static.net> Reviewed-by: Rob Pike <r@golang.org>
Diffstat (limited to 'src/time/format.go')
-rw-r--r--src/time/format.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/time/format.go b/src/time/format.go
index ed2a0a8fc6..a278cd9e6b 100644
--- a/src/time/format.go
+++ b/src/time/format.go
@@ -1135,6 +1135,9 @@ func parse(layout, value string, defaultLocation, local *Location) (Time, error)
}
case stdSecond, stdZeroSecond:
sec, value, err = getnum(value, std == stdZeroSecond)
+ if err != nil {
+ break
+ }
if sec < 0 || 60 <= sec {
rangeErrString = "second"
break