From b744a11a966ad3999c190fea9909ec8df0570b87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Fri, 17 Mar 2017 15:05:53 +0000 Subject: [PATCH] go/types: enforce Check path restrictions via panics Its godoc says that path must not be empty or dot, while the existing implementation happily accepts both. Change-Id: I64766271c35152dc7adb21ff60eb05c52237e6b6 Reviewed-on: https://go-review.googlesource.com/38262 Reviewed-by: Robert Griesemer Run-TryBot: Robert Griesemer --- src/go/types/api.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/go/types/api.go b/src/go/types/api.go index 7202828f32..7b7836fccd 100644 --- a/src/go/types/api.go +++ b/src/go/types/api.go @@ -347,6 +347,9 @@ func (init *Initializer) String() string { // file set, and the package path the package is identified with. // The clean path must not be empty or dot ("."). func (conf *Config) Check(path string, fset *token.FileSet, files []*ast.File, info *Info) (*Package, error) { + if path == "" || path == "." { + panic(`path must not be "" or "."`) + } pkg := NewPackage(path, "") return pkg, NewChecker(conf, fset, pkg, info).Files(files) }