Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #436

Merged
merged 2 commits into from Mar 29, 2017
Merged

Fixes #436

Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Prev
Prevent leak of SecurityServer and ClientServer.
They are created in SConnection's and CConnection's constructors but never destroyed.

There is no reason for the indirection, so lets make them direct members.
  • Loading branch information
michalsrb committed Mar 27, 2017
commit dccb5f7d776e93863ae10bbff56a45c523c6eeb0
5 changes: 2 additions & 3 deletions common/rfb/CConnection.cxx
Expand Up @@ -44,7 +44,6 @@ CConnection::CConnection()
state_(RFBSTATE_UNINITIALISED), useProtocol3_3(false),
framebuffer(NULL), decoder(this)
{
security = new SecurityClient();
}

CConnection::~CConnection()
Expand Down Expand Up @@ -167,7 +166,7 @@ void CConnection::processSecurityTypesMsg()
int secType = secTypeInvalid;

std::list<rdr::U8> secTypes;
secTypes = security->GetEnabledSecTypes();
secTypes = security.GetEnabledSecTypes();

if (cp.isVersion(3,3)) {

Expand Down Expand Up @@ -235,7 +234,7 @@ void CConnection::processSecurityTypesMsg()
}

state_ = RFBSTATE_SECURITY;
csecurity = security->GetCSecurity(secType);
csecurity = security.GetCSecurity(secType);
processSecurityMsg();
}

Expand Down
4 changes: 2 additions & 2 deletions common/rfb/CConnection.h
Expand Up @@ -26,6 +26,7 @@

#include <rfb/CMsgHandler.h>
#include <rfb/DecodeManager.h>
#include <rfb/SecurityClient.h>
#include <rfb/util.h>

namespace rfb {
Expand All @@ -34,7 +35,6 @@ namespace rfb {
class CMsgWriter;
class CSecurity;
class IdentityVerifier;
class SecurityClient;

class CConnection : public CMsgHandler {
public:
Expand Down Expand Up @@ -148,7 +148,7 @@ namespace rfb {
stateEnum state() { return state_; }

CSecurity *csecurity;
SecurityClient *security;
SecurityClient security;
protected:
void setState(stateEnum s) { state_ = s; }

Expand Down
12 changes: 5 additions & 7 deletions common/rfb/SConnection.cxx
Expand Up @@ -51,7 +51,7 @@ const SConnection::AccessRights SConnection::AccessFull = 0xffff;
SConnection::SConnection()
: readyForSetColourMapEntries(false),
is(0), os(0), reader_(0), writer_(0),
security(0), ssecurity(0), state_(RFBSTATE_UNINITIALISED),
ssecurity(0), state_(RFBSTATE_UNINITIALISED),
preferredEncoding(encodingRaw)
{
defaultMajorVersion = 3;
Expand All @@ -60,8 +60,6 @@ SConnection::SConnection()
defaultMinorVersion = 3;

cp.setVersion(defaultMajorVersion, defaultMinorVersion);

security = new SecurityServer();
}

SConnection::~SConnection()
Expand Down Expand Up @@ -142,7 +140,7 @@ void SConnection::processVersionMsg()

std::list<rdr::U8> secTypes;
std::list<rdr::U8>::iterator i;
secTypes = security->GetEnabledSecTypes();
secTypes = security.GetEnabledSecTypes();

if (cp.isVersion(3,3)) {

Expand All @@ -161,7 +159,7 @@ void SConnection::processVersionMsg()
os->writeU32(*i);
if (*i == secTypeNone) os->flush();
state_ = RFBSTATE_SECURITY;
ssecurity = security->GetSSecurity(*i);
ssecurity = security.GetSSecurity(*i);
processSecurityMsg();
return;
}
Expand Down Expand Up @@ -193,7 +191,7 @@ void SConnection::processSecurityType(int secType)
std::list<rdr::U8> secTypes;
std::list<rdr::U8>::iterator i;

secTypes = security->GetEnabledSecTypes();
secTypes = security.GetEnabledSecTypes();
for (i=secTypes.begin(); i!=secTypes.end(); i++)
if (*i == secType) break;
if (i == secTypes.end())
Expand All @@ -204,7 +202,7 @@ void SConnection::processSecurityType(int secType)

try {
state_ = RFBSTATE_SECURITY;
ssecurity = security->GetSSecurity(secType);
ssecurity = security.GetSSecurity(secType);
} catch (rdr::Exception& e) {
throwConnFailedException(e.str());
}
Expand Down
2 changes: 1 addition & 1 deletion common/rfb/SConnection.h
Expand Up @@ -196,7 +196,7 @@ namespace rfb {
rdr::OutStream* os;
SMsgReader* reader_;
SMsgWriter* writer_;
SecurityServer *security;
SecurityServer security;
SSecurity* ssecurity;
stateEnum state_;
rdr::S32 preferredEncoding;
Expand Down