10
10
*
11
11
*
12
12
* IDENTIFICATION
13
- * $PostgreSQL: pgsql/src/backend/libpq/hba.c,v 1.129 2004/08/29 05:06:43 momjian Exp $
13
+ * $PostgreSQL: pgsql/src/backend/libpq/hba.c,v 1.130 2004/09/18 01:22:58 tgl Exp $
14
14
*
15
15
*-------------------------------------------------------------------------
16
16
*/
@@ -213,6 +213,9 @@ next_token(FILE *fp, char *buf, int bufsz)
213
213
* Tokenize file and handle file inclusion and comma lists. We have
214
214
* to break apart the commas to expand any file names then
215
215
* reconstruct with commas.
216
+ *
217
+ * The result is always a palloc'd string. If it's zero-length then
218
+ * we have reached EOL.
216
219
*/
217
220
static char *
218
221
next_token_expand (FILE * file )
@@ -225,7 +228,7 @@ next_token_expand(FILE *file)
225
228
do
226
229
{
227
230
next_token (file , buf , sizeof (buf ));
228
- if (!* buf )
231
+ if (!buf [ 0 ] )
229
232
break ;
230
233
231
234
if (buf [strlen (buf ) - 1 ] == ',' )
@@ -382,7 +385,7 @@ tokenize_file(FILE *file, List **lines, List **line_nums)
382
385
buf = next_token_expand (file );
383
386
384
387
/* add token to list, unless we are at EOL or comment start */
385
- if (buf [0 ] != '\0' )
388
+ if (buf [0 ])
386
389
{
387
390
if (current_line == NIL )
388
391
{
@@ -403,6 +406,8 @@ tokenize_file(FILE *file, List **lines, List **line_nums)
403
406
current_line = NIL ;
404
407
/* Advance line number whenever we reach EOL */
405
408
line_number ++ ;
409
+ /* Don't forget to pfree the next_token_expand result */
410
+ pfree (buf );
406
411
}
407
412
}
408
413
}
0 commit comments