mirror of
https://github.com/google/go-jsonnet.git
synced 2025-08-06 22:37:23 +02:00
Fix an out-of-bounds array access when formatting some empty comment
This commit is contained in:
parent
5b5bcd566a
commit
6d83c91d49
2
formatter/testdata/empty_comment.fmt.golden
vendored
Normal file
2
formatter/testdata/empty_comment.fmt.golden
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
//
|
||||
{}
|
2
formatter/testdata/empty_comment.jsonnet
vendored
Normal file
2
formatter/testdata/empty_comment.jsonnet
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
#
|
||||
{}
|
@ -38,7 +38,7 @@ func (c *EnforceCommentStyle) FodderElement(p pass.ASTPass, element *ast.FodderE
|
||||
*comment = "#" + (*comment)[2:]
|
||||
}
|
||||
if c.Options.CommentStyle == CommentStyleSlash && (*comment)[0] == '#' {
|
||||
if !c.seenFirstFodder && (*comment)[1] == '!' {
|
||||
if !c.seenFirstFodder && len(*comment) > 1 && (*comment)[1] == '!' {
|
||||
return
|
||||
}
|
||||
*comment = "//" + (*comment)[1:]
|
||||
|
Loading…
Reference in New Issue
Block a user