protinfo: Check if object is nil

Avoid segfaults in certain environments by checking if the Stringer
interface pointer receiver function is `nil` and return "<nil>" in
those scenarios.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
This commit is contained in:
James O. D. Hunt 2018-07-04 14:01:34 +01:00 committed by Flavio Crisciani
parent a06dabf159
commit d77c86a2e2

View File

@ -18,6 +18,10 @@ type Protinfo struct {
// String returns a list of enabled flags
func (prot *Protinfo) String() string {
if prot == nil {
return "<nil>"
}
var boolStrings []string
if prot.Hairpin {
boolStrings = append(boolStrings, "Hairpin")