Fix free before use in ipropd_master slaves-stats open function
Signed-off-by: Love Hornquist Astrand <lha@h5l.org>
This commit is contained in:

committed by
Love Hornquist Astrand

parent
511cd18458
commit
eface6d31f
@@ -813,26 +813,28 @@ static FILE *
|
|||||||
open_stats(krb5_context context)
|
open_stats(krb5_context context)
|
||||||
{
|
{
|
||||||
char *statfile = NULL;
|
char *statfile = NULL;
|
||||||
const char *fn;
|
const char *fn = NULL;
|
||||||
int ret;
|
FILE *out = NULL;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* krb5_config_get_string_default() returs default value as-is,
|
||||||
|
* delay free() of "statfile" until we're done with "fn".
|
||||||
|
*/
|
||||||
if (slave_stats_file)
|
if (slave_stats_file)
|
||||||
fn = slave_stats_file;
|
fn = slave_stats_file;
|
||||||
else {
|
else if (asprintf(&statfile, "%s/slaves-stats", hdb_db_dir(context)) != -1
|
||||||
ret = asprintf(&statfile, "%s/slaves-stats", hdb_db_dir(context));
|
&& statfile != NULL)
|
||||||
if (ret == -1)
|
|
||||||
return NULL;
|
|
||||||
fn = krb5_config_get_string_default(context,
|
fn = krb5_config_get_string_default(context,
|
||||||
NULL,
|
NULL,
|
||||||
statfile,
|
statfile,
|
||||||
"kdc",
|
"kdc",
|
||||||
"iprop-stats",
|
"iprop-stats",
|
||||||
NULL);
|
NULL);
|
||||||
|
if (fn != NULL)
|
||||||
|
out = fopen(fn, "w");
|
||||||
|
if (statfile != NULL)
|
||||||
free(statfile);
|
free(statfile);
|
||||||
}
|
return out;
|
||||||
if (fn == NULL)
|
|
||||||
return NULL;
|
|
||||||
return fopen(fn, "w");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Reference in New Issue
Block a user