From a26bebefcedcaffd508a769eb4366484cdd0d635 Mon Sep 17 00:00:00 2001 From: Arne Redlich Date: Mon, 17 Feb 2014 23:42:42 +0100 Subject: [PATCH] nfs_opendir2_cb: plug potential memleaks Spotted by clang analyzer Signed-off-by: Arne Redlich --- lib/libnfs.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/libnfs.c b/lib/libnfs.c index eab8fd2..9dbd234 100644 --- a/lib/libnfs.c +++ b/lib/libnfs.c @@ -2729,6 +2729,7 @@ static void nfs_opendir2_cb(struct rpc_context *rpc, int status, void *command_d nfsdirent->name = strdup(entry->name); if (nfsdirent->name == NULL) { data->cb(-ENOMEM, nfs, "Failed to allocate dirent->name", data->private_data); + free(nfsdirent); nfs_free_nfsdir(nfsdir); data->continue_data = NULL; free_nfs_cb_data(data); @@ -2788,6 +2789,9 @@ static void nfs_opendir2_cb(struct rpc_context *rpc, int status, void *command_d * commands in flight to complete */ if (rdpe_cb_data->getattrcount > 0) { + nfs_free_nfsdir(nfsdir); + data->continue_data = NULL; + free_nfs_cb_data(data); rdpe_cb_data->status = RPC_STATUS_ERROR; free(rdpe_lookup_cb_data); return; @@ -2805,7 +2809,6 @@ static void nfs_opendir2_cb(struct rpc_context *rpc, int status, void *command_d } } - static void nfs_opendir_cb(struct rpc_context *rpc, int status, void *command_data, void *private_data) { READDIRPLUS3res *res = command_data; -- 2.34.1