From: Nathan Hoad Date: Fri, 11 Mar 2016 15:03:20 +0000 (+1300) Subject: Fix memory leak of lastAclData X-Git-Tag: SQUID_4_0_8~45 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b0e14ce2a74e479beac2b4ca05df7fa1ed3b71c3;p=thirdparty%2Fsquid.git Fix memory leak of lastAclData --- diff --git a/src/AccessLogEntry.cc b/src/AccessLogEntry.cc index 488555d159..1bc599c161 100644 --- a/src/AccessLogEntry.cc +++ b/src/AccessLogEntry.cc @@ -76,7 +76,6 @@ AccessLogEntry::~AccessLogEntry() HTTPMSGUNLOCK(adapted_request); safe_free(lastAclName); - safe_free(lastAclData); HTTPMSGUNLOCK(reply); HTTPMSGUNLOCK(request); diff --git a/src/AccessLogEntry.h b/src/AccessLogEntry.h index 044c31089f..5968ab2f0f 100644 --- a/src/AccessLogEntry.h +++ b/src/AccessLogEntry.h @@ -42,7 +42,6 @@ public: AccessLogEntry() : url(nullptr), lastAclName(nullptr), - lastAclData(nullptr), reply(nullptr), request(nullptr), adapted_request(nullptr) @@ -207,7 +206,7 @@ public: #endif const char *lastAclName; ///< string for external_acl_type %ACL format code - const char *lastAclData; ///< string for external_acl_type %DATA format code + SBuf lastAclData; ///< string for external_acl_type %DATA format code HierarchyLogEntry hier; HttpReply *reply; diff --git a/src/external_acl.cc b/src/external_acl.cc index 9671129988..9326989bcc 100644 --- a/src/external_acl.cc +++ b/src/external_acl.cc @@ -742,7 +742,7 @@ makeExternalAclKey(ACLFilledChecklist * ch, external_acl_data * acl_data) } } - ch->al->lastAclData = xstrdup(sb.c_str()); + ch->al->lastAclData = sb; } #if USE_IDENT diff --git a/src/format/Format.cc b/src/format/Format.cc index bfcc133fb0..c096aa4ee3 100644 --- a/src/format/Format.cc +++ b/src/format/Format.cc @@ -1381,7 +1381,8 @@ Format::Format::assemble(MemBuf &mb, const AccessLogEntry::Pointer &al, int logS break; case LFT_EXT_ACL_DATA: - out = al->lastAclData; + if (!al->lastAclData.isEmpty()) + out = al->lastAclData.c_str(); break; }