Handle nil values in conversion.EnforcePtr()

Signed-off-by: Vojtech Vitek (V-Teq) <vvitek@redhat.com>
This commit is contained in:
Vojtech Vitek (V-Teq)
2014-10-27 15:01:24 +01:00
parent 6a6f24b126
commit 8969f0df7e
2 changed files with 11 additions and 0 deletions

View File

@@ -118,5 +118,8 @@ func EnforcePtr(obj interface{}) (reflect.Value, error) {
}
return reflect.Value{}, fmt.Errorf("expected pointer, but got %v type", v.Type().Name())
}
if v.IsNil() {
return reflect.Value{}, fmt.Errorf("expected pointer, but got nil")
}
return v.Elem(), nil
}