10
10
*
11
11
*
12
12
* IDENTIFICATION
13
- * $PostgreSQL: pgsql/src/backend/libpq/hba.c,v 1.191 2009/10/01 01:58:57 tgl Exp $
13
+ * $PostgreSQL: pgsql/src/backend/libpq/hba.c,v 1.192 2009/10/03 20:04:39 tgl Exp $
14
14
*
15
15
*-------------------------------------------------------------------------
16
16
*/
@@ -804,16 +804,12 @@ parse_hba_line(List *line, int line_num, HbaLine *parsedline)
804
804
token , gai_strerror (ret )),
805
805
errcontext ("line %d of configuration file \"%s\"" ,
806
806
line_num , HbaFileName )));
807
- if (cidr_slash )
808
- * cidr_slash = '/' ;
809
807
if (gai_result )
810
808
pg_freeaddrinfo_all (hints .ai_family , gai_result );
809
+ pfree (token );
811
810
return false;
812
811
}
813
812
814
- if (cidr_slash )
815
- * cidr_slash = '/' ;
816
-
817
813
memcpy (& parsedline -> addr , gai_result -> ai_addr ,
818
814
gai_result -> ai_addrlen );
819
815
pg_freeaddrinfo_all (hints .ai_family , gai_result );
@@ -824,18 +820,22 @@ parse_hba_line(List *line, int line_num, HbaLine *parsedline)
824
820
if (pg_sockaddr_cidr_mask (& parsedline -> mask , cidr_slash + 1 ,
825
821
parsedline -> addr .ss_family ) < 0 )
826
822
{
823
+ * cidr_slash = '/' ; /* restore token for message */
827
824
ereport (LOG ,
828
825
(errcode (ERRCODE_CONFIG_FILE_ERROR ),
829
826
errmsg ("invalid CIDR mask in address \"%s\"" ,
830
827
token ),
831
828
errcontext ("line %d of configuration file \"%s\"" ,
832
829
line_num , HbaFileName )));
830
+ pfree (token );
833
831
return false;
834
832
}
833
+ pfree (token );
835
834
}
836
835
else
837
836
{
838
837
/* Read the mask field. */
838
+ pfree (token );
839
839
line_item = lnext (line_item );
840
840
if (!line_item )
841
841
{
@@ -1266,7 +1266,7 @@ check_hba(hbaPort *port)
1266
1266
}
1267
1267
1268
1268
/*
1269
- * Free the contents of a hba record
1269
+ * Free an HbaLine structure
1270
1270
*/
1271
1271
static void
1272
1272
free_hba_record (HbaLine * record )
@@ -1275,6 +1275,8 @@ free_hba_record(HbaLine *record)
1275
1275
pfree (record -> database );
1276
1276
if (record -> role )
1277
1277
pfree (record -> role );
1278
+ if (record -> usermap )
1279
+ pfree (record -> usermap );
1278
1280
if (record -> pamservice )
1279
1281
pfree (record -> pamservice );
1280
1282
if (record -> ldapserver )
@@ -1287,6 +1289,7 @@ free_hba_record(HbaLine *record)
1287
1289
pfree (record -> krb_server_hostname );
1288
1290
if (record -> krb_realm )
1289
1291
pfree (record -> krb_realm );
1292
+ pfree (record );
1290
1293
}
1291
1294
1292
1295
/*
@@ -1355,20 +1358,22 @@ load_hba(void)
1355
1358
{
1356
1359
/* Parse error in the file, so indicate there's a problem */
1357
1360
free_hba_record (newline );
1358
- pfree ( newline ) ;
1361
+ ok = false ;
1359
1362
1360
1363
/*
1361
1364
* Keep parsing the rest of the file so we can report errors on
1362
1365
* more than the first row. Error has already been reported in the
1363
1366
* parsing function, so no need to log it here.
1364
1367
*/
1365
- ok = false;
1366
1368
continue ;
1367
1369
}
1368
1370
1369
1371
new_parsed_lines = lappend (new_parsed_lines , newline );
1370
1372
}
1371
1373
1374
+ /* Free the temporary lists */
1375
+ free_lines (& hba_lines , & hba_line_nums );
1376
+
1372
1377
if (!ok )
1373
1378
{
1374
1379
/* Parsing failed at one or more rows, so bail out */
@@ -1380,9 +1385,6 @@ load_hba(void)
1380
1385
clean_hba_list (parsed_hba_lines );
1381
1386
parsed_hba_lines = new_parsed_lines ;
1382
1387
1383
- /* Free the temporary lists */
1384
- free_lines (& hba_lines , & hba_line_nums );
1385
-
1386
1388
return true;
1387
1389
}
1388
1390
0 commit comments