1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-30 17:18:21 +03:00

coverity: avoid memleak

When security_level was set, allocated filename was leaking.
This commit is contained in:
Zdenek Kabelac 2017-11-05 18:39:05 +01:00
parent 14d0b0bbdd
commit 56b527a6fb
2 changed files with 10 additions and 4 deletions

View File

@ -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.

View File

@ -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.");
@ -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;