All pastes #2076963 Raw Edit

Martin Blumenstingl

public diff v1 · immutable
#2076963 ·published 2011-06-08 21:42 UTC
rendered paste body
Index: src/xf_p2p.cpp===================================================================--- src/xf_p2p.cpp	(revision 73)+++ src/xf_p2p.cpp	(working copy)@@ -174,8 +174,14 @@             memcpy(&type, datagram.constData() + 40 + 8 + 4, 2);              Xfire::PeerToPeerPacket *packet = Xfire::PeerToPeerPacket::parseData(datagram.mid(40 + 8));-            if(!packet || !packet->isValid())+            if(!packet)             {+                kDebug() << "Corrupt DL packet received, ignoring";+                break;+            }+            else if (!packet->isValid())+            {+                delete packet;                 kDebug() << "Invalid DL packet received, ignoring";                 break;             }@@ -277,6 +283,8 @@                 break;             }             }++            delete packet;         }          // Acknowledge packetIndex: src/xf_p2p_session.cpp===================================================================--- src/xf_p2p_session.cpp	(revision 73)+++ src/xf_p2p_session.cpp	(working copy)@@ -25,8 +25,18 @@ #include "xf_p2p_session.h" #include "xf_server.h" -XfireP2PSession::XfireP2PSession(XfireContact *p_contact, const QString &p_salt) : QObject(p_contact),-    m_contact(p_contact), m_p2p(p_contact->m_account->m_p2pConnection), m_pingRetries(0), m_natType(0), m_sequenceId(0), m_handshakeDone(FALSE), m_triedLocalAddress(FALSE)+XfireP2PSession::XfireP2PSession(XfireContact *p_contact, const QString &p_salt)+    : QObject(p_contact)+    , m_p2p(p_contact->m_account->m_p2pConnection)+    , m_contact(p_contact)+    , m_natType(0)+    , m_handshakeDone(FALSE)+    , m_triedLocalAddress(FALSE)+    , m_sequenceId(0)+    , m_timer(new QTimer(this))+    , m_lastKeepAlive(new QTime())+    , m_lastPing(new QTime())+    , m_pingRetries(0) {     kDebug() << m_contact->m_username + ": creating P2P session"; @@ -53,6 +63,8 @@     delete m_lastPing;     delete m_lastKeepAlive;     m_timer->stop();++    qDeleteAll(m_fileTransfers); }  void XfireP2PSession::setLocalAddress(quint32 p_ip, quint16 p_port)@@ -66,10 +78,8 @@     m_remoteIp = p_ip;     m_remotePort = p_port; -    m_lastPing = new QTime();-    m_lastKeepAlive = new QTime();--    m_timer = new QTimer(this);+    m_lastPing->restart();+    m_lastKeepAlive->restart();     m_timer->start(1000);      QObject::connect(m_timer, SIGNAL(timeout()), this, SLOT(slotCheckSession()));Index: src/xf_server.cpp===================================================================--- src/xf_server.cpp	(revision 73)+++ src/xf_server.cpp	(working copy)@@ -147,7 +147,6 @@         }          handlePacket(packet);-        delete packet;          m_buffer.remove(0, len);     }@@ -771,6 +770,9 @@     default:         break;     }++    // We don't need the packet anymore: remove it from memory.+    delete p_packet; }  void XfireServer::slotAddedInfoEventActionActivated(uint p_actionId)Index: src/xf_games_manager.cpp===================================================================--- src/xf_games_manager.cpp	(revision 73)+++ src/xf_games_manager.cpp	(working copy)@@ -52,6 +52,7 @@  XfireGamesManager::~XfireGamesManager() {+    delete m_dialog; }  void XfireGamesManager::slotDetectionPathChanged(const KUrl &p_url)Index: src/xf_contact.cpp===================================================================--- src/xf_contact.cpp	(revision 73)+++ src/xf_contact.cpp	(working copy)@@ -89,6 +89,7 @@  XfireContact::~XfireContact() {+    slotRemoveP2pSession(); }  void XfireContact::updateAvatar()@@ -229,8 +230,11 @@  void XfireContact::slotRemoveP2pSession() {-    delete m_p2pSession;-    m_p2pSession = 0L;+    if(m_p2pSession)+    {+        delete m_p2pSession;+        m_p2pSession = 0L;+    } }  void XfireContact::deleteContact()