From: Tom Lane Date: Sat, 18 Sep 2004 01:23:12 +0000 (+0000) Subject: Fix memory leak in tokenize_file, per report from Vadim Passynkov. X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=3b949d8c92fa44f64658c441fd62f2063fda93e2;p=users%2Fbernd%2Fpostgres.git Fix memory leak in tokenize_file, per report from Vadim Passynkov. --- diff --git a/src/backend/libpq/hba.c b/src/backend/libpq/hba.c index 0f508e9102..9532ab65f5 100644 --- a/src/backend/libpq/hba.c +++ b/src/backend/libpq/hba.c @@ -168,6 +168,9 @@ next_token(FILE *fp, char *buf, const int bufsz) * Tokenize file and handle file inclusion and comma lists. We have * to break apart the commas to expand any file names then * reconstruct with commas. + * + * The result is always a palloc'd string. If it's zero-length then + * we have reached EOL. */ static char * next_token_expand(FILE *file) @@ -333,6 +336,8 @@ tokenize_file(FILE *file) { /* we are at real or logical EOL, so force a new line List */ next_line = NIL; + /* Don't forget to pfree the next_token_expand result */ + pfree(buf); } /* Advance line number whenever we reach EOL */