d236685
From 797913a0c470da93d44201d074d343953a38589c Mon Sep 17 00:00:00 2001
d236685
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
d236685
Date: Fri, 11 Mar 2011 11:06:20 +0100
d236685
Subject: [PATCH] Fix ddquot buffer leak
d236685
d236685
The ddquot buffer is used to tranfer data from/to file. All its data are
d236685
copied from/to it, so it's not needed after return from qtree_read_dquot()/
d236685
qtree_write_dquot().
d236685
---
d236685
 quotaio_tree.c |    3 +++
d236685
 1 files changed, 3 insertions(+), 0 deletions(-)
d236685
d236685
diff --git a/quotaio_tree.c b/quotaio_tree.c
d236685
index cdc0e8f..9f87889 100644
d236685
--- a/quotaio_tree.c
d236685
+++ b/quotaio_tree.c
d236685
@@ -272,6 +272,7 @@ void qtree_write_dquot(struct dquot *dquot)
d236685
 	lseek(dquot->dq_h->qh_fd, dquot->dq_dqb.u.v2_mdqb.dqb_off, SEEK_SET);
d236685
 	info->dqi_ops->mem2disk_dqblk(ddquot, dquot);
d236685
 	ret = write(dquot->dq_h->qh_fd, ddquot, info->dqi_entry_size);
d236685
+	free(ddquot);
d236685
 	if (ret != info->dqi_entry_size) {
d236685
 		if (ret > 0)
d236685
 			errno = ENOSPC;
d236685
@@ -421,11 +422,13 @@ struct dquot *qtree_read_dquot(struct quota_handle *h, qid_t id)
d236685
 		if (ret != info->dqi_entry_size) {
d236685
 			if (ret > 0)
d236685
 				errno = EIO;
d236685
+			free(ddquot);
d236685
 			die(2, _("Cannot read quota structure for id %u: %s\n"), dquot->dq_id,
d236685
 			    strerror(errno));
d236685
 		}
d236685
 		info->dqi_ops->disk2mem_dqblk(dquot, ddquot);
d236685
 	}
d236685
+	free(ddquot);
d236685
 	return dquot;
d236685
 }
d236685
 
d236685
-- 
d236685
1.7.4
d236685