Fix trivial memory leaks

Fixed trivial memory leaks detected by ASAN when running internal test
suite.
This commit is contained in:
Markus Mäkelä 2017-12-27 11:56:39 +02:00
parent 26b2a4b15d
commit 8ef681d8cd
3 changed files with 6 additions and 1 deletions

View File

@ -33,6 +33,7 @@
#include <maxscale/paths.h>
#include <maxscale/log_manager.h>
#include <maxscale/random_jkiss.h>
#include <maxscale/alloc.h>
#include "internal/secrets.h"
@ -183,6 +184,7 @@ int main(int argc, char **argv)
if (enc)
{
printf("%s\n", enc);
MXS_FREE(enc);
}
else
{

View File

@ -105,11 +105,12 @@ SERVICE* service_alloc(const char *name, const char *router)
SERVICE *service = (SERVICE *)MXS_CALLOC(1, sizeof(*service));
SERVICE_REFRESH_RATE* rate_limits = (SERVICE_REFRESH_RATE*)MXS_CALLOC(config_threadcount(),
sizeof(*rate_limits));
if (!my_name || !my_router || !service)
if (!my_name || !my_router || !service || !rate_limits)
{
MXS_FREE(my_name);
MXS_FREE(my_router);
MXS_FREE(service);
MXS_FREE(rate_limits);
return NULL;
}
@ -131,6 +132,7 @@ SERVICE* service_alloc(const char *name, const char *router)
MXS_FREE(my_name);
MXS_FREE(my_router);
MXS_FREE(service);
MXS_FREE(rate_limits);
return NULL;
}

View File

@ -845,5 +845,6 @@ int main(int argc, char **argv)
mxs_log_finish();
MXS_FREE(inst);
MXS_FREE(roptions);
return 0;
}