summaryrefslogtreecommitdiff
path: root/lib/ss
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2009-02-23 18:26:05 +0100
committerTheodore Ts'o <tytso@mit.edu>2009-03-08 20:38:47 -0400
commit671326f6251d88d27fe7f299f7ede4a452dfca61 (patch)
tree52407dcb3307ef4f5609cc9bca5e0256ca28c9f6 /lib/ss
parent4e711be8d04cb6da9e3e3628f82ee66bfbda23f2 (diff)
downloade2fsprogs-671326f6251d88d27fe7f299f7ede4a452dfca61.tar.gz
libss: Avoid leak upon failed realloc in ss_add_request_table()
Signed-off-by: Jim Meyering <meyering@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'lib/ss')
-rw-r--r--lib/ss/request_tbl.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/ss/request_tbl.c b/lib/ss/request_tbl.c
index 4027af85..4632d65d 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;