MT#59962 XMLRPC2DI: properly free heap allocated objects

For the `XMLRPC2DIServer` class as well as for the
`XMLRPC2DI` one, heap allocated objects aren't properly
managed by destruction time.

Pointers have to be initialized as NULL, and point
only when allocation was successfull.
Then by a destruction time, check them and free.

Change-Id: I1a31813db254cc4ab0f7ecc7b382fcb3635feee0
mr13.3.1
Donat Zenichev 1 year ago
parent dafa639f2a
commit 168d6ee84c

@ -66,7 +66,7 @@ XMLRPC2DI* XMLRPC2DI::instance()
return _instance;
}
XMLRPC2DI::XMLRPC2DI(const string& mod_name)
XMLRPC2DI::XMLRPC2DI(const string& mod_name)
: AmDynInvokeFactory(mod_name)
{
}
@ -348,7 +348,8 @@ XMLRPC2DIServer::XMLRPC2DIServer(unsigned int port,
getcpsavg_method(s),
getcpsmax_method(s),
getcpslimit_method(s),
setcpslimit_method(s)
setcpslimit_method(s),
s(NULL), di_method(NULL)
{
INFO("XMLRPC Server: enabled builtin method 'calls'\n");
INFO("XMLRPC Server: enabled builtin method 'get_loglevel'\n");

@ -134,6 +134,15 @@ class XMLRPC2DIServer
bool multithreaded = false,
unsigned int threads = 5);
~XMLRPC2DIServer() {
if (s) {
delete s;
}
if (di_method) {
delete di_method;
}
}
bool initialize();
void run();
@ -188,7 +197,11 @@ class XMLRPC2DI
public:
XMLRPC2DI(const string& mod_name);
~XMLRPC2DI() { }
~XMLRPC2DI() {
if (server) {
delete server;
}
}
int onLoad();
// DI factory

Loading…
Cancel
Save