diff --git a/examples/cpp/MacProxy/main.cpp b/examples/cpp/MacProxy/main.cpp index 84bb2194a..90596baf5 100644 --- a/examples/cpp/MacProxy/main.cpp +++ b/examples/cpp/MacProxy/main.cpp @@ -58,6 +58,8 @@ std::string GetProxyForURL(const std::string& url) urlProxArrayRef = CFNetworkCopyProxiesForURL(urlRef, proxyDicRef); if (!urlProxArrayRef) goto cleanup; + if (CFArrayGetCount(urlProxArrayRef) == 0) + goto cleanup; defProxyDic = (CFDictionaryRef)CFArrayGetValueAtIndex(urlProxArrayRef, 0); if (!defProxyDic) @@ -82,11 +84,6 @@ std::string GetProxyForURL(const std::string& url) cleanup: - if (hostNameRef) - { - CFRelease(hostNameRef); - hostNameRef = NULL; - } if (urlProxArrayRef) { CFRelease(urlProxArrayRef); diff --git a/lib/api/LogManagerFactory.cpp b/lib/api/LogManagerFactory.cpp index 0f6a31171..f6e68a5c3 100644 --- a/lib/api/LogManagerFactory.cpp +++ b/lib/api/LogManagerFactory.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -33,9 +34,9 @@ namespace MAT_NS_BEGIN ILogManager* LogManagerFactory::Create(ILogConfiguration& configuration) { LOCKGUARD(ILogManagerInternal::managers_lock); - auto logManager = new LogManagerImpl(configuration); - ILogManagerInternal::managers.emplace(logManager); - return logManager; + auto logManager = std::make_unique(configuration); + ILogManagerInternal::managers.emplace(logManager.get()); + return logManager.release(); } /// @@ -254,4 +255,3 @@ namespace MAT_NS_BEGIN } MAT_NS_END - diff --git a/lib/system/EventProperty.cpp b/lib/system/EventProperty.cpp index 6d0582440..cce939ee8 100644 --- a/lib/system/EventProperty.cpp +++ b/lib/system/EventProperty.cpp @@ -504,6 +504,11 @@ namespace MAT_NS_BEGIN { /// EventProperty& EventProperty::operator=(const EventProperty& source) { + if (this == &source) + { + return *this; + } + clear(); memcpy((void*)this, (void*)&source, sizeof(EventProperty)); copydata(&source); @@ -958,4 +963,3 @@ namespace MAT_NS_BEGIN { } } MAT_NS_END - diff --git a/lib/tracing/api/DebugProviders.hpp b/lib/tracing/api/DebugProviders.hpp index 90f6740af..61669a673 100644 --- a/lib/tracing/api/DebugProviders.hpp +++ b/lib/tracing/api/DebugProviders.hpp @@ -344,8 +344,8 @@ class ETWStringStream : public DebugStringStream { guid.Data4[6] = buffer2[14]; guid.Data4[7] = buffer2[15]; - delete buffer; - delete buffer2; + delete[] buffer; + delete[] buffer2; return guid; } @@ -393,4 +393,3 @@ class ETWStringStream : public DebugStringStream { #endif #endif - diff --git a/tests/unittests/EventPropertiesTests.cpp b/tests/unittests/EventPropertiesTests.cpp index d2867340b..9e8a408c0 100644 --- a/tests/unittests/EventPropertiesTests.cpp +++ b/tests/unittests/EventPropertiesTests.cpp @@ -114,6 +114,15 @@ TEST(EventPropertiesTests, Properties) EXPECT_THAT(ep.GetPiiProperties(), IsEmpty()); } +TEST(EventPropertiesTests, SelfAssignmentPreservesValue) +{ + EventProperty property("value"); + + property = property; + + EXPECT_EQ(property, EventProperty("value")); +} + TEST(EventPropertiesTests, NumericProperties) { EventProperties ep("test");