Skip to content

tls: fix leak of WriteWrap+TLSWrap combination

Rodrigo Muino Tomonari requested to merge github/fork/indutny/fix/tls-leak into master
Checklist
  • make -j8 test (UNIX), or vcbuild test nosign (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)

tls

Description of change

Writing data to TLSWrap instance during handshake will result in it being queued in write_item_queue_. This queue won't get cleared up until the end of the handshake.

Technically, it gets cleared on ~TLSWrap invocation, however this won't ever happen because every WriteWrap holds a reference to the TLSWrap through JS object, meaning that they are doomed to be alive for eternity.

To breach this dreadful contract a knight shall embark from the close function to kill the dragon of memory leak with his magic spear of destroySSL.

destroySSL cleans up write_item_queue_ and frees SSL structure, both are good for memory usage.

R= @bnoordhuis and @nodejs/crypto

Merge request reports

Loading