fix(Foundation): use after free warnings #4189

This commit is contained in:
Alex Fabijanic 2023-10-23 23:45:05 +02:00
parent 47ddacd004
commit cd12420495
2 changed files with 9 additions and 1 deletions

View File

@ -302,6 +302,10 @@ public:
protected: protected:
P activateObject(P pObject) P activateObject(P pObject)
{ {
#if defined(POCO_COMPILER_GCC)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wuse-after-free"
#endif
try try
{ {
_factory.activateObject(pObject); _factory.activateObject(pObject);
@ -312,6 +316,9 @@ protected:
throw; throw;
} }
return pObject; return pObject;
#if defined(POCO_COMPILER_GCC)
#pragma GCC diagnostic pop
#endif
} }
private: private:

View File

@ -13,6 +13,7 @@
#include "CppUnit/TestSuite.h" #include "CppUnit/TestSuite.h"
#include "Poco/AutoPtr.h" #include "Poco/AutoPtr.h"
#include "Poco/Exception.h" #include "Poco/Exception.h"
#include <atomic>
using Poco::AutoPtr; using Poco::AutoPtr;
@ -66,7 +67,7 @@ namespace
} }
private: private:
int _rc; std::atomic<int> _rc;
static int _count; static int _count;
}; };