You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2020/07/13 22:12:50 UTC

[trafficserver] branch 8.1.x updated: Fix memory leak in header_rewrite (#6986)

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

zwoop pushed a commit to branch 8.1.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/8.1.x by this push:
     new 526d96b  Fix memory leak in header_rewrite (#6986)
526d96b is described below

commit 526d96bce9849eec36d940734a65a3badc101788
Author: Susan Hinrichs <sh...@yahoo-inc.com>
AuthorDate: Thu Jul 9 15:07:08 2020 -0500

    Fix memory leak in header_rewrite (#6986)
    
    (cherry picked from commit 0a9c6e8b12bdb50b3f88e9a53e64051db5e1115d)
---
 plugins/header_rewrite/conditions.cc | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/plugins/header_rewrite/conditions.cc b/plugins/header_rewrite/conditions.cc
index c80d985..b42c9f9 100644
--- a/plugins/header_rewrite/conditions.cc
+++ b/plugins/header_rewrite/conditions.cc
@@ -423,12 +423,15 @@ ConditionUrl::append_value(std::string &s, const Resources &res)
     TSDebug(PLUGIN_NAME, "   Scheme to match is: %.*s", i, q_str);
     break;
   case URL_QUAL_URL:
-  case URL_QUAL_NONE:
-    q_str = TSUrlStringGet(bufp, url, &i);
-    s.append(q_str, i);
-    TSDebug(PLUGIN_NAME, "   URL to match is: %.*s", i, q_str);
+  case URL_QUAL_NONE: {
+    // TSUrlStringGet returns an allocated char * we must free
+    char *non_const_q_str = TSUrlStringGet(bufp, url, &i);
+    s.append(non_const_q_str, i);
+    TSDebug(PLUGIN_NAME, "   URL to match is: %.*s", i, non_const_q_str);
+    TSfree(non_const_q_str);
     break;
   }
+  }
 }
 
 bool