amitbet / vnc2video

A fully featured VNC client written in golang
MIT License
151 stars 39 forks source link

Update encoding_util.go #12

Open liuzheng opened 4 years ago

liuzheng commented 4 years ago

fix this panic

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x30 pc=0x96df96]

goroutine 60 [running]:
github.com/amitbet/vnc2video.(*VncCanvas).RemoveCursor(0x0, 0xc000139b00, 0xc0003faedf)
        D:/go1.13.8.windows-amd64/gopath/pkg/mod/github.com/amitbet/vnc2video@v0.0.0-20190616012314-9d50b9dab1d9/encoding_util.go:61 +0x26
github.com/amitbet/vnc2video.(*DefaultClientMessageHandler).Handle.func2(0xc0003434d0, 0xbce180, 0xc000120a00, 0xc0002e8b20, 0xc00011e500, 0xc000139b00)
        D:/go1.13.8.windows-amd64/gopath/pkg/mod/github.com/amitbet/vnc2video@v0.0.0-20190616012314-9d50b9dab1d9/client.go:303 +0x2ab
created by github.com/amitbet/vnc2video.(*DefaultClientMessageHandler).Handle
        D:/go1.13.8.windows-amd64/gopath/pkg/mod/github.com/amitbet/vnc2video@v0.0.0-20190616012314-9d50b9dab1d9/client.go:285 +0x2b8
liuzheng commented 4 years ago

I run in a goroutine, and when I create and distory frequently, it will show this panic.

I was not very sure which reason cause it, but this is my fix.