From 22fe614f7a528b209fc2075cf76274fbcb780814 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 19 Jul 2014 18:55:24 +0300 Subject: Fix memory leak with ipc port selection. --- src/net/ipc.cpp | 10 +++++++--- src/net/ipc.h | 3 +++ 2 files changed, 10 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/net/ipc.cpp b/src/net/ipc.cpp index 559c65a59..96113154f 100644 --- a/src/net/ipc.cpp +++ b/src/net/ipc.cpp @@ -22,9 +22,11 @@ #include "logger.h" -#include "gui/widgets/tabs/chattab.h" #include "gui/windows/chatwindow.h" +#include "gui/widgets/tabs/chattab.h" + +#include "utils/delete2.h" #include "utils/sdlhelper.h" #include "utils/stringutils.h" @@ -150,18 +152,20 @@ void IPC::start() port = atoi(getenv("IPC_PORT")); logger->log("Starting IPC..."); + ipc = new IPC; for (int port = 44007; port < 65535; port ++) { + ipc->setPort(port); logger->log(" -> trying port %d...", ipc_port); - ipc = new IPC(port); if (ipc->init()) { logger->log(" -> Port %d selected", ipc_port); - break; + return; } else { port ++; } } + delete2(ipc); } diff --git a/src/net/ipc.h b/src/net/ipc.h index b9960abce..611dba35c 100644 --- a/src/net/ipc.h +++ b/src/net/ipc.h @@ -49,6 +49,9 @@ public: static void stop(); private: + void setPort(const unsigned short port) + { mPort = port; } + bool mListen; unsigned int mNumReqs; unsigned short mPort; -- cgit v1.2.3-70-g09d2