Skip to content

Commit 3f369b1

Browse files
committed
instructions: avoid allocating memory and processing location for nil
Nil errors get ignored by WithLocation but the structures that create slices with location information still need to be created before they get discarded. Signed-off-by: Tonis Tiigi <[email protected]>
1 parent 4d79ae3 commit 3f369b1

File tree

1 file changed

+3
-1
lines changed
  • frontend/dockerfile/instructions

1 file changed

+3
-1
lines changed

frontend/dockerfile/instructions/parse.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ func ParseInstruction(node *parser.Node) (v interface{}, err error) {
7373
// ParseInstruction converts an AST to a typed instruction (either a command or a build stage beginning when encountering a `FROM` statement)
7474
func ParseInstructionWithLinter(node *parser.Node, lint *linter.Linter) (v interface{}, err error) {
7575
defer func() {
76-
err = parser.WithLocation(err, node.Location())
76+
if err != nil {
77+
err = parser.WithLocation(err, node.Location())
78+
}
7779
}()
7880
req := newParseRequestFromNode(node)
7981
switch strings.ToLower(node.Value) {

0 commit comments

Comments
 (0)