From: Fabian Keil <fk@fabiankeil.de>
Date: Tue, 10 Nov 2020 10:37:21 +0000 (+0100)
Subject: Fix memory leak in cgi_show_status() with extended statistics enabled
X-Git-Tag: v_3_0_29~34
X-Git-Url: http://www.privoxy.org/gitweb/%22https:/faq/@default-cgi@/coding.html?a=commitdiff_plain;h=d42f1fde45d47940d20d20eabf025a87e4769cdb;p=privoxy.git

Fix memory leak in cgi_show_status() with extended statistics enabled

CID 305235
---

diff --git a/cgisimple.c b/cgisimple.c
index 4339ecd0..592e7040 100644
--- a/cgisimple.c
+++ b/cgisimple.c
@@ -1280,26 +1280,28 @@ jb_err cgi_show_status(struct client_state *csp,
 #endif /* ndef FEATURE_STATISTICS */
 
 #ifdef FEATURE_EXTENDED_STATISTICS
+   if (!err)
    {
       char *block_reason_statistics = get_block_reason_statistics_table(csp);
       if (block_reason_statistics != NULL)
       {
-         if (!err) err = map(exports, "block-reason-statistics", 1, block_reason_statistics, 0);
+         err = map(exports, "block-reason-statistics", 1, block_reason_statistics, 0);
       }
       else
       {
-         if (!err) err = map_block_killer(exports, "extended-statistics");
+         err = map_block_killer(exports, "extended-statistics");
       }
    }
+   if (!err)
    {
       char *filter_statistics = get_filter_statistics_table(csp);
       if (filter_statistics != NULL)
       {
-         if (!err) err = map(exports, "filter-statistics", 1, filter_statistics, 0);
+         err = map(exports, "filter-statistics", 1, filter_statistics, 0);
       }
       else
       {
-         if (!err) err = map_block_killer(exports, "extended-statistics");
+         err = map_block_killer(exports, "extended-statistics");
       }
    }
 #else /* ndef FEATURE_EXTENDED_STATISTICS */