mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
coverity: avoid memleak
When security_level was set, allocated filename was leaking.
This commit is contained in:
parent
14d0b0bbdd
commit
56b527a6fb
@ -1,5 +1,6 @@
|
||||
Version 2.02.177 -
|
||||
====================================
|
||||
Fix memleak of string buffer when vgcfgbackup runs in secure mode.
|
||||
Do not print error when clvmd cannot find running clvmd.
|
||||
Prevent start of new merge of snapshot if origin is already being merged.
|
||||
|
||||
|
@ -20,8 +20,13 @@ static char *_expand_filename(const char *template, const char *vg_name,
|
||||
{
|
||||
char *filename;
|
||||
|
||||
if (security_level())
|
||||
return dm_strdup(template);
|
||||
if (security_level()) {
|
||||
if (!(filename = dm_strdup(template))) {
|
||||
log_error("Failed to allocate filename.");
|
||||
return NULL;
|
||||
}
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!(filename = dm_malloc(PATH_MAX))) {
|
||||
log_error("Failed to allocate filename.");
|
||||
@ -31,7 +36,7 @@ static char *_expand_filename(const char *template, const char *vg_name,
|
||||
if (dm_snprintf(filename, PATH_MAX, template, vg_name) < 0) {
|
||||
log_error("Error processing filename template %s",
|
||||
template);
|
||||
dm_free(filename);
|
||||
dm_free(filename);
|
||||
return NULL;
|
||||
}
|
||||
if (*last_filename && !strncmp(*last_filename, filename, PATH_MAX)) {
|
||||
@ -40,7 +45,7 @@ static char *_expand_filename(const char *template, const char *vg_name,
|
||||
dm_free(filename);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
out:
|
||||
dm_free(*last_filename);
|
||||
*last_filename = filename;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user