1010 *
1111 *
1212 * 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 $
1414 *
1515 *-------------------------------------------------------------------------
1616 */
@@ -804,16 +804,12 @@ parse_hba_line(List *line, int line_num, HbaLine *parsedline)
804804token ,gai_strerror (ret )),
805805errcontext ("line %d of configuration file \"%s\"" ,
806806line_num ,HbaFileName )));
807- if (cidr_slash )
808- * cidr_slash = '/' ;
809807if (gai_result )
810808pg_freeaddrinfo_all (hints .ai_family ,gai_result );
809+ pfree (token );
811810return false;
812811}
813812
814- if (cidr_slash )
815- * cidr_slash = '/' ;
816-
817813memcpy (& parsedline -> addr ,gai_result -> ai_addr ,
818814gai_result -> ai_addrlen );
819815pg_freeaddrinfo_all (hints .ai_family ,gai_result );
@@ -824,18 +820,22 @@ parse_hba_line(List *line, int line_num, HbaLine *parsedline)
824820if (pg_sockaddr_cidr_mask (& parsedline -> mask ,cidr_slash + 1 ,
825821parsedline -> addr .ss_family )< 0 )
826822{
823+ * cidr_slash = '/' ;/* restore token for message */
827824ereport (LOG ,
828825(errcode (ERRCODE_CONFIG_FILE_ERROR ),
829826errmsg ("invalid CIDR mask in address \"%s\"" ,
830827token ),
831828errcontext ("line %d of configuration file \"%s\"" ,
832829line_num ,HbaFileName )));
830+ pfree (token );
833831return false;
834832}
833+ pfree (token );
835834}
836835else
837836{
838837/* Read the mask field. */
838+ pfree (token );
839839line_item = lnext (line_item );
840840if (!line_item )
841841{
@@ -1266,7 +1266,7 @@ check_hba(hbaPort *port)
12661266}
12671267
12681268/*
1269- * Freethe contents of a hba record
1269+ * Freean HbaLine structure
12701270 */
12711271static void
12721272free_hba_record (HbaLine * record )
@@ -1275,6 +1275,8 @@ free_hba_record(HbaLine *record)
12751275pfree (record -> database );
12761276if (record -> role )
12771277pfree (record -> role );
1278+ if (record -> usermap )
1279+ pfree (record -> usermap );
12781280if (record -> pamservice )
12791281pfree (record -> pamservice );
12801282if (record -> ldapserver )
@@ -1287,6 +1289,7 @@ free_hba_record(HbaLine *record)
12871289pfree (record -> krb_server_hostname );
12881290if (record -> krb_realm )
12891291pfree (record -> krb_realm );
1292+ pfree (record );
12901293}
12911294
12921295/*
@@ -1355,20 +1358,22 @@ load_hba(void)
13551358{
13561359/* Parse error in the file, so indicate there's a problem */
13571360free_hba_record (newline );
1358- pfree ( newline ) ;
1361+ ok = false ;
13591362
13601363/*
13611364 * Keep parsing the rest of the file so we can report errors on
13621365 * more than the first row. Error has already been reported in the
13631366 * parsing function, so no need to log it here.
13641367 */
1365- ok = false;
13661368continue ;
13671369}
13681370
13691371new_parsed_lines = lappend (new_parsed_lines ,newline );
13701372}
13711373
1374+ /* Free the temporary lists */
1375+ free_lines (& hba_lines ,& hba_line_nums );
1376+
13721377if (!ok )
13731378{
13741379/* Parsing failed at one or more rows, so bail out */
@@ -1380,9 +1385,6 @@ load_hba(void)
13801385clean_hba_list (parsed_hba_lines );
13811386parsed_hba_lines = new_parsed_lines ;
13821387
1383- /* Free the temporary lists */
1384- free_lines (& hba_lines ,& hba_line_nums );
1385-
13861388return true;
13871389}
13881390