From 178d4697c55c7c4c932d6e1564815f3ab0a1a6d2 Mon Sep 17 00:00:00 2001 From: brain Date: Sat, 13 Oct 2007 22:58:16 +0000 Subject: [PATCH] Fixes for potential 4 byte memory leak, and crash git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8169 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_ident.cpp | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/src/modules/m_ident.cpp b/src/modules/m_ident.cpp index f522f6719..6f0f3b557 100644 --- a/src/modules/m_ident.cpp +++ b/src/modules/m_ident.cpp @@ -277,27 +277,39 @@ class ModuleIdent : public Module if (user->GetExt("ident_socket", isock)) { int *fd; - if (user->GetExt("ident_socket_fd", fd) && (ServerInstance->SE->GetRef(*fd) == isock)) + if (user->GetExt("ident_socket_fd", fd)) { - user->Shrink("ident_socket_fd"); - delete fd; - isock->Close(); + if (ServerInstance->SE->GetRef(*fd) == isock) + isock->Close(); + + /* Check again, isock->Close() can confuse us */ + if (user->GetExt("ident_socket_fd", fd)) + { + user->Shrink("ident_socket_fd"); + delete fd; + } } } } } - + virtual void OnUserDisconnect(userrec *user) { IdentRequestSocket *isock; if (user->GetExt("ident_socket", isock)) { int *fd; - if (user->GetExt("ident_socket_fd", fd) && (ServerInstance->SE->GetRef(*fd) == isock)) + if (user->GetExt("ident_socket_fd", fd)) { - user->Shrink("ident_socket_fd"); - delete fd; - isock->Close(); + if (ServerInstance->SE->GetRef(*fd) == isock) + isock->Close(); + + /* Check again, isock->Close() can confuse us */ + if (user->GetExt("ident_socket_fd", fd)) + { + user->Shrink("ident_socket_fd"); + delete fd; + } } } } -- 2.39.5