From a0914beb984ed740f31099846717128803fb5958 Mon Sep 17 00:00:00 2001 From: Chih-Wei Huang Date: Tue, 15 Apr 2014 16:23:07 +0800 Subject: [PATCH] Fix a possible memory leak In ntfs_fuse_parse_path(), it's possible that strdup() succeeds but ntfs_mbstoucs() returns a negative value. In such a case the callers just treat it as an error and ignores the allocated path buffer that results in a memory leak. --- src/ntfs-3g.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ntfs-3g.c b/src/ntfs-3g.c index 2d063427..166ef727 100644 --- a/src/ntfs-3g.c +++ b/src/ntfs-3g.c @@ -524,8 +524,11 @@ static int ntfs_fuse_parse_path(const char *org_path, char **path, if (stream_name_mbs) { *stream_name = NULL; res = ntfs_mbstoucs(stream_name_mbs, stream_name); - if (res < 0) + if (res < 0) { + free(*path); + *path = NULL; return -errno; + } return res; } } else