diff options
author | Anna Henningsen <anna@addaleax.net> | 2018-06-16 23:07:31 +0200 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2018-06-20 22:52:49 +0200 |
commit | 7a2e2fb36defb85e6b3973f5d94590fc2bbc96cc (patch) | |
tree | c509b91f9c0096632eabddb10477d3972cdf8196 /src/node_http2.h | |
parent | d362b07e78f69b52e90e026b7bb55065d6ffc484 (diff) | |
download | android-node-v8-7a2e2fb36defb85e6b3973f5d94590fc2bbc96cc.tar.gz android-node-v8-7a2e2fb36defb85e6b3973f5d94590fc2bbc96cc.tar.bz2 android-node-v8-7a2e2fb36defb85e6b3973f5d94590fc2bbc96cc.zip |
http2: fix memory leak when headers are not emitted
When headers are not emitted to JS, e.g. because of an error
before that could happen, we currently still have the vector of
previously received headers lying around, each one holding
a reference count of 1.
To fix the resulting memory leak, release them in the `Http2Stream`
destructor.
Also, clear the vector of headers once they have been emitted –
there’s not need to keep it around, wasting memory.
PR-URL: https://github.com/nodejs/node/pull/21373
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Diffstat (limited to 'src/node_http2.h')
-rw-r--r-- | src/node_http2.h | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/src/node_http2.h b/src/node_http2.h index a046ade0fd..db453c1087 100644 --- a/src/node_http2.h +++ b/src/node_http2.h @@ -592,18 +592,14 @@ class Http2Stream : public AsyncWrap, bool AddHeader(nghttp2_rcbuf* name, nghttp2_rcbuf* value, uint8_t flags); - inline nghttp2_header* headers() { - return current_headers_.data(); + inline std::vector<nghttp2_header> move_headers() { + return std::move(current_headers_); } inline nghttp2_headers_category headers_category() const { return current_headers_category_; } - inline size_t headers_count() const { - return current_headers_.size(); - } - void StartHeaders(nghttp2_headers_category category); // Required for StreamBase |