Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
5f32c8b8
Commit
5f32c8b8
authored
Mar 13, 2012
by
Brad Fitzpatrick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
html/template: fix panic on Clone
Fixes #3281 R=golang-dev, r CC=golang-dev
https://golang.org/cl/5819044
parent
d6ad6f0e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
3 deletions
+12
-3
clone_test.go
src/pkg/html/template/clone_test.go
+7
-0
template.go
src/pkg/html/template/template.go
+5
-3
No files found.
src/pkg/html/template/clone_test.go
View file @
5f32c8b8
...
...
@@ -113,3 +113,10 @@ func TestClone(t *testing.T) {
t
.
Errorf
(
"t3: got %q want %q"
,
got
,
want
)
}
}
// This used to crash; http://golang.org/issue/3281
func
TestCloneCrash
(
t
*
testing
.
T
)
{
t1
:=
New
(
"all"
)
Must
(
t1
.
New
(
"t1"
)
.
Parse
(
`{{define "foo"}}foo{{end}}`
))
t1
.
Clone
()
}
src/pkg/html/template/template.go
View file @
5f32c8b8
...
...
@@ -160,9 +160,11 @@ func (t *Template) Clone() (*Template, error) {
if
src
==
nil
||
src
.
escaped
{
return
nil
,
fmt
.
Errorf
(
"html/template: cannot Clone %q after it has executed"
,
t
.
Name
())
}
x
.
Tree
=
&
parse
.
Tree
{
Name
:
x
.
Tree
.
Name
,
Root
:
x
.
Tree
.
Root
.
CopyList
(),
if
x
.
Tree
!=
nil
{
x
.
Tree
=
&
parse
.
Tree
{
Name
:
x
.
Tree
.
Name
,
Root
:
x
.
Tree
.
Root
.
CopyList
(),
}
}
ret
.
set
[
name
]
=
&
Template
{
false
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment