From f4269fe8ac2c3b09dd01f4e020b9a80ab716f264 Mon Sep 17 00:00:00 2001 From: Susan Hinrichs Date: Wed, 8 Jul 2020 21:59:59 +0000 Subject: [PATCH] Fix memory leak in header_rewrite --- 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 8bb3848a97f..e785e266e9d 100644 --- a/plugins/header_rewrite/conditions.cc +++ b/plugins/header_rewrite/conditions.cc @@ -344,12 +344,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