]> granicus.if.org Git - pgbouncer/commitdiff
hba: initialize struct before opening file
authorMarko Kreen <markokr@gmail.com>
Fri, 4 Dec 2015 12:55:03 +0000 (14:55 +0200)
committerMarko Kreen <markokr@gmail.com>
Fri, 4 Dec 2015 12:55:03 +0000 (14:55 +0200)
Otherwise is can crash when walking uninitialized list.

Fixes: #95
src/hba.c

index 322b7d0e66781dd5c9cef30cedd3d75479c8774e..dade1d8978d1511cf4dfe8d486aa51a57e068387 100644 (file)
--- a/src/hba.c
+++ b/src/hba.c
@@ -617,11 +617,12 @@ struct HBA *hba_load_rules(const char *fn)
        if (!hba)
                goto out;
 
+       list_init(&hba->rules);
+
        f = fopen(fn, "r");
        if (!f)
                goto out;
 
-       list_init(&hba->rules);
        for (linenr = 1; ; linenr++) {
                len = getline(&ln, &lnbuf, f);
                if (len < 0)