postgres.git / summary / log / commit / refs
commit 1ff05d09a01b660285f78ffb57dbaf79c83b09b8
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date: Sat Jan 30 18:59:58 2010 +0000
First released in: 9.0.0, 8.4.3
Fix memory leakage introduced into print_aligned_text by 8.4 changes
(failure to free col_lineptrs[] array elements) and exacerbated in the
current devel cycle (failure to free "wrap"). This resulted in moderate
bloat of psql over long script runs. Noted while testing bug #5302,
although what the reporter was complaining of was backend-side leakage.
src/bin/psql/print.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/src/bin/psql/print.c b/src/bin/psql/print.c
index 4260143c447..e124531e7d6 100644
--- a/src/bin/psql/print.c
+++ b/src/bin/psql/print.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2009, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/print.c,v 1.116 2009/06/12 16:17:29 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/print.c,v 1.116.2.1 2010/01/30 18:59:58 tgl Exp $
*/
#include "postgres_fe.h"
@@ -923,6 +923,11 @@ print_aligned_text(const printTableContent *cont, FILE *fout)
}
/* clean up */
+ for (i = 0; i < col_count; i++)
+ {
+ free(col_lineptrs[i]);
+ free(format_buf[i]);
+ }
free(width_header);
free(width_average);
free(max_width);
@@ -931,11 +936,9 @@ print_aligned_text(const printTableContent *cont, FILE *fout)
free(curr_nl_line);
free(col_lineptrs);
free(max_bytes);
+ free(format_buf);
free(header_done);
free(bytes_output);
- for (i = 0; i < col_count; i++)
- free(format_buf[i]);
- free(format_buf);
if (is_pager)
ClosePager(fout);
[parent: 96b0da67ff82]