t3rm1n4l/go-mega

Unhandled error on login

vlourme opened this issue · 3 comments

Hi, I get this error which seems not handled and it causes a panic on the login method:

panic: runtime error: index out of range [0] with length 0

goroutine 8 [running]:
github.com/t3rm1n4l/go-mega.getMPI(0x1742e48, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
	/Users/vico/go/src/github.com/t3rm1n4l/go-mega/utils.go:195 +0x191
github.com/t3rm1n4l/go-mega.decryptSessionId(0x0, 0x0, 0x0, 0x0, 0xc003c53110, 0x10, 0x10, 0x0, 0x0, 0x0, ...)
	/Users/vico/go/src/github.com/t3rm1n4l/go-mega/utils.go:274 +0x15d
github.com/t3rm1n4l/go-mega.(*Mega).login(0xc0007aba40, 0xc004d59c20, 0x12, 0xc004d59c33, 0x8, 0x0, 0x0)
	/Users/vico/go/src/github.com/t3rm1n4l/go-mega/mega.go:574 +0x485
github.com/t3rm1n4l/go-mega.(*Mega).Login(0xc0007aba40, 0xc004d59c20, 0x12, 0xc004d59c33, 0x8, 0x0, 0xc0007aba40)
	/Users/vico/go/src/github.com/t3rm1n4l/go-mega/mega.go:588 +0x8c
ncw commented

It looks like privk and csid are both empty when passed into decryptSessionId

We could put a test in for that and return an error but I don't think it would solve the problem.

How did you cause this error?

I got this error after connecting multiple times in a go routine (maybe this is caused threading?)

ncw commented

Can you paste or show the code?