This is an automated email from the ASF dual-hosted git repository.

amc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new 92a912e  Issue 5604 - fix memory leaks for http parser.
92a912e is described below

commit 92a912e2a250bcf8ef32827fe5b2207f8110370f
Author: Alan M. Carroll <[email protected]>
AuthorDate: Mon Aug 5 11:43:16 2019 -0500

    Issue 5604 - fix memory leaks for http parser.
---
 proxy/hdrs/MIME.h    | 3 ++-
 proxy/http/HttpSM.cc | 9 ++-------
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/proxy/hdrs/MIME.h b/proxy/hdrs/MIME.h
index 06e9630..ebf1677 100644
--- a/proxy/hdrs/MIME.h
+++ b/proxy/hdrs/MIME.h
@@ -348,7 +348,8 @@ MIMEScanner::get_buffered_line_size() const
 inline void
 MIMEScanner::clear()
 {
-  m_line.clear();
+  std::string empty;        // GAH! @c swap isn't defined to take r-value 
reference!
+  std::swap(m_line, empty); // make sure the memory is released.
   m_state = INITIAL_PARSE_STATE;
 }
 
diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc
index 9dc242d..5751e2f 100644
--- a/proxy/http/HttpSM.cc
+++ b/proxy/http/HttpSM.cc
@@ -281,10 +281,7 @@ HttpVCTable::cleanup_all()
     default_handler = _h;                 \
   }
 
-HttpSM::HttpSM() : Continuation(nullptr), vc_table(this)
-{
-  ink_zero(http_parser);
-}
+HttpSM::HttpSM() : Continuation(nullptr), vc_table(this) {}
 
 void
 HttpSM::cleanup()
@@ -334,6 +331,7 @@ HttpSM::init()
   t_state.txn_conf = &t_state.http_config_param->oride;
 
   t_state.init();
+  http_parser_init(&http_parser);
 
   // Added to skip dns if the document is in cache. DNS will be forced if 
there is a ip based ACL in
   // cache control or parent.config or if the doc_in_cache_skip_dns is 
disabled or if http caching is disabled
@@ -341,8 +339,6 @@ HttpSM::init()
   t_state.force_dns = (ip_rule_in_CacheControlTable() || 
t_state.parent_params->parent_table->ipMatch ||
                        !(t_state.txn_conf->doc_in_cache_skip_dns) || 
!(t_state.txn_conf->cache_http));
 
-  http_parser_init(&http_parser);
-
   SET_HANDLER(&HttpSM::main_handler);
 
 #ifdef USE_HTTP_DEBUG_LISTS
@@ -520,7 +516,6 @@ HttpSM::attach_client_session(ProxyTransaction *client_vc, 
IOBufferReader *buffe
   ua_entry->vc_handler = &HttpSM::state_read_client_request_header;
   t_state.hdr_info.client_request.destroy();
   t_state.hdr_info.client_request.create(HTTP_TYPE_REQUEST);
-  http_parser_init(&http_parser);
 
   // Prepare raw reader which will live until we are sure this is HTTP indeed
   if (is_transparent_passthrough_allowed() || (ssl_vc && 
ssl_vc->decrypt_tunnel())) {

Reply via email to