]> Cypherpunks repositories - gostls13.git/commit
strconv: check for empty string in UnquoteChar
authorRebecca Stambler <rstambler@golang.org>
Mon, 4 Jun 2018 19:12:45 +0000 (15:12 -0400)
committerHeschi Kreinick <heschi@google.com>
Mon, 4 Jun 2018 22:06:42 +0000 (22:06 +0000)
commitb219a68ad957462470695bcd0333e24ea9bdf08c
tree5df5664f53a7ae9b47ddbf6a10e198280e486980
parentd0228b03bd77e048504877797e53e3f16b149d8f
strconv: check for empty string in UnquoteChar

The existing implementation panics on malformed input of an empty
string. strconv.Unquote validates the length of the inputs, but calling
UnquoteChar directly with an empty string leads to a panic, so add a
check for length. Also, add a test to go/constant to ensure that
MakeFromLiteral does not panic on malformed input such as
"const x = ''".

Change-Id: I4217e38db48a09a21ec414bbfb3087709da62904
Reviewed-on: https://go-review.googlesource.com/116215
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
src/go/constant/value_test.go
src/strconv/quote.go