From c71b47b9e61fbee863a650db1ea8125949ef2acc Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Mon, 13 Feb 2012 14:39:24 +0000 Subject: [PATCH] Fix missing temp_buf init for error path In previous commit this was missing, also deallocate in reversed order. --- libdm/libdm-common.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libdm/libdm-common.c b/libdm/libdm-common.c index 6e719d044..8d0fea343 100644 --- a/libdm/libdm-common.c +++ b/libdm/libdm-common.c @@ -1188,7 +1188,7 @@ const char *dm_uuid_prefix(void) static int _sysfs_get_dm_name(uint32_t major, uint32_t minor, char *buf, size_t buf_size) { - char *sysfs_path, *temp_buf; + char *sysfs_path, *temp_buf = NULL; FILE *fp = NULL; int r = 0; size_t len; @@ -1232,15 +1232,15 @@ bad: if (fp && fclose(fp)) log_sys_error("fclose", sysfs_path); - dm_free(sysfs_path); dm_free(temp_buf); + dm_free(sysfs_path); return r; } static int _sysfs_get_kernel_name(uint32_t major, uint32_t minor, char *buf, size_t buf_size) { - char *sysfs_path, *temp_buf, *name; + char *name, *sysfs_path, *temp_buf = NULL; ssize_t size; size_t len; int r = 0; @@ -1281,8 +1281,8 @@ static int _sysfs_get_kernel_name(uint32_t major, uint32_t minor, char *buf, siz strcpy(buf, name); r = 1; bad: - dm_free(sysfs_path); dm_free(temp_buf); + dm_free(sysfs_path); return r; }