mirror of
https://github.com/znc/znc.git
synced 2026-03-28 17:42:41 +01:00
Fix #1248: segfault in shell module.
It happened when client disconnects.
This commit is contained in:
@@ -49,6 +49,9 @@ class CShellSock : public CExecSock {
|
||||
void ReadLine(const CString& sData) override;
|
||||
void Disconnected() override;
|
||||
|
||||
bool IsOfClient(CClient* pClient) const { return pClient == m_pClient; }
|
||||
bool IsOfModule(CShellMod* pParent) const { return pParent == m_pParent; }
|
||||
|
||||
CShellMod* m_pParent;
|
||||
|
||||
private:
|
||||
@@ -117,6 +120,21 @@ class CShellMod : public CModule {
|
||||
"SHELL");
|
||||
}
|
||||
|
||||
void OnClientDisconnect() override {
|
||||
std::vector<Csock*> vDeadCommands;
|
||||
for (Csock* pSock : *GetManager()) {
|
||||
if (CShellSock* pSSock = dynamic_cast<CShellSock*>(pSock)) {
|
||||
if (pSSock->IsOfModule(this) &&
|
||||
pSSock->IsOfClient(GetClient())) {
|
||||
vDeadCommands.push_back(pSock);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Csock* pSock : vDeadCommands) {
|
||||
GetManager()->DelSockByAddr(pSock);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
CString m_sPath;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user