light: fix memory leak

regression from f235b76900
This commit is contained in:
Thomas Schoebel-Theuer 2016-03-01 09:39:24 +01:00 committed by Thomas Schoebel-Theuer
parent 708547b2f4
commit a312e3d93b

View File

@ -2473,29 +2473,32 @@ void _create_new_logfile(const char *path)
}
}
static
const char *__get_link_path(const char *_linkpath, const char **linkpath)
{
const char *res = mars_readlink(_linkpath);
if (linkpath)
*linkpath = _linkpath;
else
brick_string_free(_linkpath);
return res;
}
static
const char *get_replaylink(const char *parent_path, const char *host, const char **linkpath)
{
const char * _linkpath = path_make("%s/replay-%s", parent_path, host);
*linkpath = _linkpath;
if (unlikely(!_linkpath)) {
MARS_ERR("no MEM\n");
return NULL;
}
return mars_readlink(_linkpath);
return __get_link_path(_linkpath, linkpath);
}
static
const char *get_versionlink(const char *parent_path, int seq, const char *host, const char **linkpath)
{
const char * _linkpath = path_make("%s/version-%09d-%s", parent_path, seq, host);
if (linkpath)
*linkpath = _linkpath;
if (unlikely(!_linkpath)) {
MARS_ERR("no MEM\n");
return NULL;
}
return mars_readlink(_linkpath);
return __get_link_path(_linkpath, linkpath);
}
static inline