From: Fabian Keil <fk@fabiankeil.de>
Date: Thu, 24 Sep 2020 08:44:00 +0000 (+0200)
Subject: pcrs_filter_response(): Free the old data if there are no hits
X-Git-Tag: v_3_0_29~82
X-Git-Url: http://www.privoxy.org/gitweb/%22https:/developer-manual/man-page/@default-cgi@send-stylesheet?a=commitdiff_plain;h=5cfb7bc8feecc82eb161450faa572abf9be19cbb;p=privoxy.git

pcrs_filter_response(): Free the old data if there are no hits

... and it's different from the data in iob and the new data.

Fixes a memory leak if multiple filters are executed
and the last one is skipped due to a pcre error.
---

diff --git a/filters.c b/filters.c
index 13cba16a..7b586bc0 100644
--- a/filters.c
+++ b/filters.c
@@ -1671,6 +1671,10 @@ static char *pcrs_filter_response(struct client_state *csp)
     */
    if (!hits)
    {
+      if (old != csp->iob->cur && old != new)
+      {
+         freez(old);
+      }
       freez(new);
       return(NULL);
    }