janimo / textsecure

TextSecure client package for Go
GNU General Public License v3.0
129 stars 26 forks source link

Segfualt if you don't initialize #7

Closed relyt29 closed 9 years ago

relyt29 commented 9 years ago

Hey,

If you don't run textsecure.Setup(client) before trying to textsecure.SendMessage(), your code will segfault on line 315 of store.go in the sessionFilePath function:

func (s *store) sessionFilePath(recipientID string, deviceID uint32) string {
    return filepath.Join(s.sessionsDir, fmt.Sprintf("%s_%d", recipientID, deviceID))
}

this segfaults because if you don't Setup() properly s is nil: 0x0. Obviously that was my fault for not reading the docs properly and running Setup first but you may consider returning an error rather than segfaulting. Up to you

janimo commented 9 years ago

Thanks, I agree more error handling is needed throughout the code, it's just that the current API is definitely not final so I did not put too much work in checking it is used well.

relyt29 commented 9 years ago

I can try to write an automated testing file a la the instructions here: http://www.golang-book.com/12/index.htm

but that's lower priority for me than finishing the ncurses frontend.

janimo commented 9 years ago

Keep up the work on the ncurses frontend :)

janimo commented 9 years ago

Closing as invalid.