From: Jim Meyering <jim@meyering.net>
To: linux-ext4@vger.kernel.org
Subject: [PATCH] * request_tbl.c (ss_add_request_table): Avoid leak upon failed realloc.
Date: Mon, 23 Feb 2009 18:26:05 +0100 [thread overview]
Message-ID: <87ocwtcbf6.fsf@meyering.net> (raw)
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(-)
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;
--
1.6.2.rc1.266.g4bdf
next reply other threads:[~2009-02-23 17:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-23 17:26 Jim Meyering [this message]
2009-03-09 0:40 ` [PATCH] * request_tbl.c (ss_add_request_table): Avoid leak upon failed realloc Theodore Tso
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ocwtcbf6.fsf@meyering.net \
--to=jim@meyering.net \
--cc=linux-ext4@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).