Commit db5a8791 authored by Ilkka Myller's avatar Ilkka Myller
Browse files

https: fix memory leak with https.request()

If calling `https.request()` with `options.headers.host` defined
and `options.servername` undefined, `https.Agent.createSocket` mutates
connection `options` after `https.Agent.addRequest` has created empty
socket pool array with mismatching connection name. This results in two
socket pool arrays being created and only the last one gets eventually
deleted by `removeSocket` - causing a memory leak.

This commit fixes the leak by making sure that `addRequest` does the
same modifications to `options` object as the `createSocket`.

`createSocket` is intentionally left unmodified to prevent userland
regressions.

Test case included.

PR-URL: https://github.com/nodejs/node/pull/8647
Fixes: https://github.com/nodejs/node/issues/6687


Reviewed-By: default avatarFedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: default avatarColin Ihrig <cjihrig@gmail.com>
Reviewed-By: default avatarJackson Tian <shvyo1987@gmail.com>
Reviewed-By: default avatarJames M Snell <jasnell@gmail.com>
parent c5ce7f4d
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment