security-context: avoid UB in C macro (#8229)
to safely use wl_container_of with a class the class has to be no virtual functions, no inheritance, and uniform access control (e.g all public) work around this by putting this into a destroywrapper struct.
This commit is contained in:
parent
3cec45d821
commit
f0e023bff2
2 changed files with 17 additions and 7 deletions
|
|
@ -37,14 +37,20 @@ class CSecurityContextManagerResource {
|
|||
SP<CWpSecurityContextManagerV1> resource;
|
||||
};
|
||||
|
||||
class CSecurityContextSandboxedClient;
|
||||
struct CSecurityContextSandboxedClientDestroyWrapper {
|
||||
wl_listener listener;
|
||||
CSecurityContextSandboxedClient* parent = nullptr;
|
||||
};
|
||||
|
||||
class CSecurityContextSandboxedClient {
|
||||
public:
|
||||
static SP<CSecurityContextSandboxedClient> create(int clientFD);
|
||||
~CSecurityContextSandboxedClient();
|
||||
|
||||
void onDestroy();
|
||||
void onDestroy();
|
||||
|
||||
wl_listener destroyListener;
|
||||
CSecurityContextSandboxedClientDestroyWrapper destroyListener;
|
||||
|
||||
private:
|
||||
CSecurityContextSandboxedClient(int clientFD_);
|
||||
|
|
@ -81,4 +87,4 @@ class CSecurityContextProtocol : public IWaylandProtocol {
|
|||
|
||||
namespace PROTO {
|
||||
inline UP<CSecurityContextProtocol> securityContext;
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue