Fix memory leak in tokenize_file, per report from Vadim Passynkov.
authorTom Lane <[email protected]>
Sat, 18 Sep 2004 01:23:12 +0000 (01:23 +0000)
committerTom Lane <[email protected]>
Sat, 18 Sep 2004 01:23:12 +0000 (01:23 +0000)
src/backend/libpq/hba.c

index 0f508e910298a594ad86d343bc8a8fbd1a8edb53..9532ab65f5ffc84648b5aad95cbc10e1c2d41799 100644 (file)
@@ -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 */