From: Arne Redlich Date: Mon, 17 Feb 2014 22:42:42 +0000 (+0100) Subject: nfs_opendir2_cb: plug potential memleaks X-Git-Tag: upstream/1.9.6^2~97 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=a26bebefcedcaffd508a769eb4366484cdd0d635;p=deb_libnfs.git nfs_opendir2_cb: plug potential memleaks Spotted by clang analyzer Signed-off-by: Arne Redlich --- 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;