Skip to content
This repository was archived by the owner on Nov 28, 2024. It is now read-only.

Fix writeBody may get panic because of nil w.partWriter#64

Open
mikechen1199 wants to merge 1 commit intogo-mail:v2from
mikechen1199:v2
Open

Fix writeBody may get panic because of nil w.partWriter#64
mikechen1199 wants to merge 1 commit intogo-mail:v2from
mikechen1199:v2

Conversation

@mikechen1199
Copy link

  • If (*messageWriter).createPart fails, w.err will be set and
    w.partWriter will be nil.
  • (*messageWriter).writeBody do not check the w.err and the
    w.partWriter. It may try to use the nil w.partWriter, causing
    "panic: runtime error: invalid memory address or nil pointer
    dereference".
  • Adding the check of w.err, just like (*messageWriter).Write, do
    nothing in (*messageWriter).writeBody if w.err is not nil.

- If (*messageWriter).createPart fails, w.err will be set and
  w.partWriter will be nil.
- (*messageWriter).writeBody do not check the w.err and the
  w.partWriter. It may try to use the nil w.partWriter, causing
  "panic: runtime error: invalid memory address or nil pointer
  dereference".
- Adding the check of w.err, just like (*messageWriter).Write, do
  nothing in (*messageWriter).writeBody if w.err is not nil.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant