hdb: don't use lock_file name after free in open_lock_file

This commit is contained in:
Daria Phoebe Brashear
2020-01-12 23:53:02 -05:00
committed by Nico Williams
parent efba1c21e9
commit 59d132f825

View File

@@ -136,6 +136,7 @@ static krb5_error_code
open_lock_file(krb5_context context, const char *db_name, int *fd)
{
char *lock_file;
int ret = 0;
/* lock old and new databases */
asprintf(&lock_file, "%s.lock", db_name);
@@ -145,14 +146,13 @@ open_lock_file(krb5_context context, const char *db_name, int *fd)
}
*fd = open(lock_file, O_RDWR | O_CREAT, 0600);
free(lock_file);
if(*fd < 0) {
int ret = errno;
ret = errno;
krb5_set_error_message(context, ret, "open(%s): %s", lock_file,
strerror(ret));
return ret;
}
return 0;
free(lock_file);
return ret;
}