From b80e8364d08fa38c7a094b3ad22cbf743ec80efd Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 7 Jul 2014 15:21:46 -0700 Subject: [PATCH] terraform: fix potential nil access on graph --- terraform/context.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/terraform/context.go b/terraform/context.go index 2c2df5ee82..166d144971 100644 --- a/terraform/context.go +++ b/terraform/context.go @@ -241,13 +241,15 @@ func (c *Context) Validate() ([]string, []error) { // Walk the graph and validate all the configs var warns []string var errs []error - err = g.Walk(c.validateWalkFn(&warns, &errs)) - if err != nil { - rerr = multierror.ErrorAppend(rerr, fmt.Errorf( - "Error validating resources in graph: %s", err)) - } - if len(errs) > 0 { - rerr = multierror.ErrorAppend(rerr, errs...) + if g != nil { + err = g.Walk(c.validateWalkFn(&warns, &errs)) + if err != nil { + rerr = multierror.ErrorAppend(rerr, fmt.Errorf( + "Error validating resources in graph: %s", err)) + } + if len(errs) > 0 { + rerr = multierror.ErrorAppend(rerr, errs...) + } } errs = nil