Git-commit: dccb5f7d776e93863ae10bbff56a45c523c6eeb0
Patch-Mainline: Upstream
References: bnc#1031886
From: Michal Srb <michalsrb@gmail.com>
Subject: 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.

Index: tigervnc-1.4.3/common/rfb/CConnection.cxx
===================================================================
--- tigervnc-1.4.3.orig/common/rfb/CConnection.cxx
+++ tigervnc-1.4.3/common/rfb/CConnection.cxx
@@ -37,7 +37,6 @@ CConnection::CConnection()
     shared(false),
     state_(RFBSTATE_UNINITIALISED), useProtocol3_3(false)
 {
-  security = new SecurityClient();
 }
 
 CConnection::~CConnection()
@@ -124,7 +123,7 @@ void CConnection::processSecurityTypesMs
   int secType = secTypeInvalid;
 
   std::list<rdr::U8> secTypes;
-  secTypes = security->GetEnabledSecTypes();
+  secTypes = security.GetEnabledSecTypes();
 
   if (cp.isVersion(3,3)) {
 
@@ -192,7 +191,7 @@ void CConnection::processSecurityTypesMs
   }
 
   state_ = RFBSTATE_SECURITY;
-  csecurity = security->GetCSecurity(secType);
+  csecurity = security.GetCSecurity(secType);
   processSecurityMsg();
 }
 
Index: tigervnc-1.4.3/common/rfb/CConnection.h
===================================================================
--- tigervnc-1.4.3.orig/common/rfb/CConnection.h
+++ tigervnc-1.4.3/common/rfb/CConnection.h
@@ -132,7 +132,7 @@ namespace rfb {
     stateEnum state() { return state_; }
 
     CSecurity *csecurity;
-    SecurityClient *security;
+    SecurityClient security;
   protected:
     void setState(stateEnum s) { state_ = s; }
 
Index: tigervnc-1.4.3/common/rfb/SConnection.cxx
===================================================================
--- tigervnc-1.4.3.orig/common/rfb/SConnection.cxx
+++ tigervnc-1.4.3/common/rfb/SConnection.cxx
@@ -48,7 +48,7 @@ const SConnection::AccessRights SConnect
 SConnection::SConnection(bool reverseConnection_)
   : readyForSetColourMapEntries(false),
     is(0), os(0), reader_(0), writer_(0),
-    security(0), ssecurity(0), state_(RFBSTATE_UNINITIALISED),
+    ssecurity(0), state_(RFBSTATE_UNINITIALISED),
     reverseConnection(reverseConnection_),
     preferredEncoding(encodingRaw)
 {
@@ -58,8 +58,6 @@ SConnection::SConnection(bool reverseCon
     defaultMinorVersion = 3;
 
   cp.setVersion(defaultMajorVersion, defaultMinorVersion);
-
-  security = new SecurityServer();
 }
 
 SConnection::~SConnection()
@@ -145,7 +143,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)) {
 
@@ -164,7 +162,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;
   }
@@ -196,7 +194,7 @@ void SConnection::processSecurityType(in
   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())
@@ -207,7 +205,7 @@ void SConnection::processSecurityType(in
 
   try {
     state_ = RFBSTATE_SECURITY;
-    ssecurity = security->GetSSecurity(secType);
+    ssecurity = security.GetSSecurity(secType);
   } catch (rdr::Exception& e) {
     throwConnFailedException(e.str());
   }
Index: tigervnc-1.4.3/common/rfb/SConnection.h
===================================================================
--- tigervnc-1.4.3.orig/common/rfb/SConnection.h
+++ tigervnc-1.4.3/common/rfb/SConnection.h
@@ -197,7 +197,7 @@ namespace rfb {
     rdr::OutStream* os;
     SMsgReader* reader_;
     SMsgWriter* writer_;
-    SecurityServer *security;
+    SecurityServer security;
     SSecurity* ssecurity;
     stateEnum state_;
     bool reverseConnection;
