]> Cypherpunks.ru repositories - gostls13.git/commit
html/template: handle nil Error values in context.String
authorSamuel Tan <samueltan@gmail.com>
Tue, 11 Jun 2019 05:18:56 +0000 (22:18 -0700)
committerDmitri Shuralyov <dmitshur@golang.org>
Mon, 17 Jun 2019 19:12:05 +0000 (19:12 +0000)
commitdb042d2d42e1009bb9d6c12a7a018108638e1dae
tree5c19271495eaec41e5f9ea2dad96bcc9acd3eae6
parent530097fe60c3d9feffabf52ea910bf35af9da6fb
html/template: handle nil Error values in context.String

Add a special case to print a generic nil error when context.err is
nil.

Previously, this case was unchecked, leading to a call to (*Error).Error
with a nil receiver, which was triggering a nil pointer access. However,
this bug was masked by the panic-recovery code in package fmt.

I tested this change by running `dlv test` in src/html/template, running
the `continue` command, and verifying that no "bad access" errors are
returned.

Fixes #28854

Change-Id: I0b637b943de003d9efc294f6f1e49b793668d037
Reviewed-on: https://go-review.googlesource.com/c/go/+/181579
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
src/html/template/context.go