agl / pond

Pond
BSD 3-Clause "New" or "Revised" License
911 stars 109 forks source link

cli.go crash when attaching file directly to contact #125

Closed asn-d6 closed 9 years ago

asn-d6 commented 9 years ago

In the CLI mode, the user is supposed to attach a file to a draft. If the user attaches a file to a contact (assuming that the file will be sent on its own) pond will crash with nil pointer dereference.

This is because the code doesn't return after the following error case (there was no draft to attach to):

case attachCommand:
    draft, ok := c.currentObj.(*Draft)
    if !ok {
        c.Printf("%s Select draft first\n", termWarnPrefix)
    }

This seems to be the case also in the removeCommand case.

burdges commented 9 years ago

Reproduced. Patch tacked onto another pull request : https://github.com/burdges/pond/commit/53b50d9c8944e5c1df5ba18650e096ef338564cd

agl commented 9 years ago

Thanks! Should be fixed now with 65830f65c209e38affc3f232638150618c7010e9