From a579cf57906f45a2a26d46b3dde0b6dae2615333 Mon Sep 17 00:00:00 2001 From: ieee0824 Date: Thu, 12 Oct 2017 17:57:32 +0900 Subject: [PATCH] fix nil bug --- cryptex.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cryptex.go b/cryptex.go index d8296e7..ed66058 100644 --- a/cryptex.go +++ b/cryptex.go @@ -10,6 +10,7 @@ import ( "io/ioutil" "os" "os/exec" + "fmt" ) const ( @@ -196,6 +197,9 @@ func (c *Cryptex) Decrypt(d *Container) (interface{}, error) { } func (c *Cryptex) Edit(i *Container) (interface{}, error) { + if i == nil || i.Values == nil { + return nil, fmt.Errorf("container is empty") + } p, err := c.decrypt(i.Values) if err != nil { return nil, err