diff mbox

* request_tbl.c (ss_add_request_table): Avoid leak upon failed realloc.

Message ID 87ocwtcbf6.fsf@meyering.net
State Accepted, archived
Headers show

Commit Message

Jim Meyering Feb. 23, 2009, 5:26 p.m. UTC
Signed-off-by: Jim Meyering <meyering@redhat.com>
---
Here's another found via inspection.
It looks like it can only affect debugfs.

 lib/ss/request_tbl.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

--
1.6.2.rc1.266.g4bdf
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Theodore Ts'o March 9, 2009, 12:40 a.m. UTC | #1
Thanks, applied.

						- Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/lib/ss/request_tbl.c b/lib/ss/request_tbl.c
index 4027af8..4632d65 100644
--- a/lib/ss/request_tbl.c
+++ b/lib/ss/request_tbl.c
@@ -27,18 +27,19 @@  void ss_add_request_table(sci_idx, rqtbl_ptr, position, code_ptr)
 {
 	register ss_data *info;
 	register int i, size;
+	ssrt **t;

 	info = ss_info(sci_idx);
 	for (size=0; info->rqt_tables[size] != (ssrt *)NULL; size++)
 		;
 	/* size == C subscript of NULL == #elements */
 	size += 2;		/* new element, and NULL */
-	info->rqt_tables = (ssrt **)realloc(info->rqt_tables,
-					    (unsigned)size*sizeof(ssrt));
-	if (info->rqt_tables == (ssrt **)NULL) {
+	t = (ssrt **)realloc(info->rqt_tables, (unsigned)size*sizeof(ssrt));
+	if (t == (ssrt **)NULL) {
 		*code_ptr = errno;
 		return;
 	}
+	info->rqt_tables = t;
 	if (position > size - 2)
 		position = size - 2;