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:Fedor Indutny <fedor.indutny@gmail.com> Reviewed-By:
Colin Ihrig <cjihrig@gmail.com> Reviewed-By:
Jackson Tian <shvyo1987@gmail.com> Reviewed-By:
James M Snell <jasnell@gmail.com>
parent
c5ce7f4d
Please register or sign in to comment