From e4bf04aeeaa8e6fb4f503011a1267c28d68ae5e4 Mon Sep 17 00:00:00 2001 From: szaka Date: Thu, 15 Jan 2009 16:56:10 +0000 Subject: [PATCH] ntfs_attr_open: fix named attribute memory leak in error cases (Jean-Pierre Andre) --- libntfs-3g/attrib.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libntfs-3g/attrib.c b/libntfs-3g/attrib.c index 77ed8a48..a11299c8 100644 --- a/libntfs-3g/attrib.c +++ b/libntfs-3g/attrib.c @@ -376,6 +376,7 @@ ntfs_attr *ntfs_attr_open(ntfs_inode *ni, const ATTR_TYPES type, { ntfs_attr_search_ctx *ctx; ntfs_attr *na = NULL; + ntfschar *newname = NULL; ATTR_RECORD *a; BOOL cs; @@ -393,6 +394,7 @@ ntfs_attr *ntfs_attr_open(ntfs_inode *ni, const ATTR_TYPES type, name = ntfs_ucsndup(name, name_len); if (!name) goto err_out; + newname = name; } ctx = ntfs_attr_get_search_ctx(ni, NULL); @@ -410,6 +412,7 @@ ntfs_attr *ntfs_attr_open(ntfs_inode *ni, const ATTR_TYPES type, a->name_offset)), a->name_length); if (!name) goto put_err_out; + newname = name; name_len = a->name_length; } else { name = AT_UNNAMED; @@ -471,6 +474,7 @@ out: put_err_out: ntfs_attr_put_search_ctx(ctx); err_out: + free(newname); free(na); na = NULL; goto out;