From 468b46bc6448b43d1e4713e22fcae089f27e85b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bryon=20Gloden=2C=20CISSP=C2=AE?= Date: Thu, 11 Aug 2016 18:22:57 -0400 Subject: [PATCH 1/4] Update test_P_DNS.cc [iocore/dns/test_P_DNS.cc:74]: (error) Memory leak: str --- iocore/dns/test_P_DNS.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/iocore/dns/test_P_DNS.cc b/iocore/dns/test_P_DNS.cc index 11509606d5b..9d6bb38200a 100644 --- a/iocore/dns/test_P_DNS.cc +++ b/iocore/dns/test_P_DNS.cc @@ -70,6 +70,7 @@ struct NetTesterSM : public Continuation { default: ink_release_assert(!"unknown event"); } + delete(str); return EVENT_CONT; } }; From 2841e179725e8be84cea2dc57cb999cff018f131 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bryon=20Gloden=2C=20CISSP=C2=AE?= Date: Thu, 11 Aug 2016 18:25:14 -0400 Subject: [PATCH 2/4] Update test_P_Net.cc [iocore/net/test_P_Net.cc:72]: (error) Memory leak: str --- iocore/net/test_P_Net.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/iocore/net/test_P_Net.cc b/iocore/net/test_P_Net.cc index 5bf9c68ad4b..84ae8981df1 100644 --- a/iocore/net/test_P_Net.cc +++ b/iocore/net/test_P_Net.cc @@ -68,6 +68,7 @@ struct NetTesterSM : public Continuation { default: ink_release_assert(!"unknown event"); } + delete(str); return EVENT_CONT; } }; From b186b8ddbad8f0a4bb18c3d6f20ef3939b1cae3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bryon=20Gloden=2C=20CISSP=C2=AE?= Date: Thu, 11 Aug 2016 18:52:26 -0400 Subject: [PATCH 3/4] Update test_P_Net.cc There's no guarantee that delete will work on arrays. In C++ we call this undefined behaviour -- it might work, it might not, it might do something totally random and unexpected. We'd be best to avoid relying on undefined behavior. REF: http://stackoverflow.com/a/6953502 --- iocore/dns/test_P_DNS.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iocore/dns/test_P_DNS.cc b/iocore/dns/test_P_DNS.cc index 9d6bb38200a..b0dae2d7e7f 100644 --- a/iocore/dns/test_P_DNS.cc +++ b/iocore/dns/test_P_DNS.cc @@ -70,7 +70,7 @@ struct NetTesterSM : public Continuation { default: ink_release_assert(!"unknown event"); } - delete(str); + delete [] str; return EVENT_CONT; } }; From 71ea17958896b83cf186c632ed27fae66bfae35e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bryon=20Gloden=2C=20CISSP=C2=AE?= Date: Thu, 11 Aug 2016 18:53:31 -0400 Subject: [PATCH 4/4] Update test_P_Net.cc There's no guarantee that delete will work on arrays. In C++ we call this undefined behaviour -- it might work, it might not, it might do something totally random and unexpected. We'd be best to avoid relying on undefined behavior. REF: http://stackoverflow.com/a/6953502 --- iocore/net/test_P_Net.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iocore/net/test_P_Net.cc b/iocore/net/test_P_Net.cc index 84ae8981df1..626915a5a82 100644 --- a/iocore/net/test_P_Net.cc +++ b/iocore/net/test_P_Net.cc @@ -68,7 +68,7 @@ struct NetTesterSM : public Continuation { default: ink_release_assert(!"unknown event"); } - delete(str); + delete [] str; return EVENT_CONT; } };