go-gomail / gomail

The best way to send emails in Go.
MIT License
4.32k stars 572 forks source link

panic: runtime error: invalid memory address or nil pointer dereference #75

Closed chindax closed 7 years ago

chindax commented 7 years ago

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

goroutine 1 [running]: panic(0x5bbce0, 0xc42000c0c0) /usr/local/go/src/runtime/panic.go:500 +0x1a1 other_lib/gomail.(base64LineWriter).Write(0xc420340e60, 0xc42017adb8, 0x400, 0x400, 0xc4200b6000, 0x300, 0x8000) /home/silence/golang/src/other_lib/gomail/writeto.go:292 +0x70 encoding/base64.(encoder).Write(0xc42017ad80, 0xc4200b6000, 0x8000, 0x8000, 0x8000, 0x0, 0x0) /usr/local/go/src/encoding/base64/base64.go:188 +0x2cb io.copyBuffer(0x7f68f45270c0, 0xc42017ad80, 0x6b7c20, 0xc4200d8018, 0xc4200b6000, 0x8000, 0x8000, 0xc4200d8018, 0x0, 0x0) /usr/local/go/src/io/io.go:392 +0x260 io.Copy(0x7f68f45270c0, 0xc42017ad80, 0x6b7c20, 0xc4200d8018, 0x0, 0x4129df, 0x5beb60) /usr/local/go/src/io/io.go:360 +0x68 other_lib/gomail.(Message).appendFile.func1(0x7f68f45270c0, 0xc42017ad80, 0xc42017ad80, 0x7f68f45270c0) /home/silence/golang/src/other_lib/gomail/message.go:295 +0x7d other_lib/gomail.(messageWriter).writeBody(0xc42039c540, 0xc420011dc0, 0x5ed85d, 0x6) /home/silence/golang/src/other_lib/gomail/writeto.go:264 +0x2e0 other_lib/gomail.(messageWriter).addFiles(0xc42039c540, 0xc420026078, 0x1, 0x1, 0x1) /home/silence/golang/src/other_lib/gomail/writeto.go:145 +0x1aa other_lib/gomail.(messageWriter).writeMessage(0xc42039c540, 0xc4200acff0) /home/silence/golang/src/other_lib/gomail/writeto.go:53 +0x226 other_lib/gomail.(Message).WriteTo(0xc4200acff0, 0x7f68f44f4660, 0xc42036f860, 0x7f68f44f4660, 0xc42036f860, 0xc42000d810) /home/silence/golang/src/other_lib/gomail/writeto.go:17 +0x8e other_lib/gomail.(smtpSender).Send(0xc42036f700, 0xc42036f780, 0x15, 0xc42036ab90, 0x1, 0x1, 0x6b7d20, 0xc4200acff0, 0x1, 0x6f0520) /home/silence/golang/src/other_lib/gomail/smtp.go:171 +0x1a9 other_lib/gomail.send(0x7f68f44f4638, 0xc42036f700, 0xc4200acff0, 0x0, 0xc420159848) /home/silence/golang/src/other_lib/gomail/send.go:57 +0xdc other_lib/gomail.Send(0x7f68f44f4638, 0xc42036f700, 0xc42009f990, 0x1, 0x1, 0x70, 0x5df540) /home/silence/golang/src/other_lib/gomail/send.go:38 +0x7a other_lib/gomail.(*Dialer).DialAndSend(0xc4200527e0, 0xc42009f990, 0x1, 0x1, 0x0, 0x0) /home/silence/golang/src/other_lib/gomail/smtp.go:137 +0xe9 main.sendMail(0xc420076200, 0xc42000d630, 0x10, 0xc4200b0c00, 0x11, 0x20, 0x0, 0x0) /home/silence/golang/src/customsSendMail/main.go:236 +0x8c2

source: issue_code

chindax commented 7 years ago

This specialStr will too long, include many picture format string and chinese string.

chindax commented 7 years ago

I found this bug, parse string is failed.