pgpool2.git / summary / log / commit / refs
commit 30fcacccfd3dc9f26933f4b4377ecfbfb51effbf
Author: Tatsuo Ishii <ishii@sraoss.co.jp>
Date: Mon Jul 08 04:20:08 2019 +0000
Fix memory leak pointed out by Coverity.
When failed to create a connection to backend, new_connection() failed
to free memory.
src/protocol/pool_connection_pool.c | 24 ++++++++++++++----------
1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/src/protocol/pool_connection_pool.c b/src/protocol/pool_connection_pool.c
index 56db092ef..2c3ba11f3 100644
--- a/src/protocol/pool_connection_pool.c
+++ b/src/protocol/pool_connection_pool.c
@@ -893,6 +893,8 @@ static POOL_CONNECTION_POOL * new_connection(POOL_CONNECTION_POOL * p)
if (create_cp(s, i) == NULL)
{
+ pfree(s);
+
/*
* If failover_on_backend_error is true, do failover. Otherwise,
* just exit this session or skip next health node.
@@ -947,19 +949,21 @@ static POOL_CONNECTION_POOL * new_connection(POOL_CONNECTION_POOL * p)
}
child_exit(POOL_EXIT_AND_RESTART);
}
+ else
+ {
+ p->info[i].create_time = time(NULL);
+ p->slots[i] = s;
- p->info[i].create_time = time(NULL);
- p->slots[i] = s;
-
- pool_init_params(&s->con->params);
+ pool_init_params(&s->con->params);
- if (BACKEND_INFO(i).backend_status != CON_UP)
- {
- BACKEND_INFO(i).backend_status = CON_UP;
- pool_set_backend_status_changed_time(i);
- status_changed = true;
+ if (BACKEND_INFO(i).backend_status != CON_UP)
+ {
+ BACKEND_INFO(i).backend_status = CON_UP;
+ pool_set_backend_status_changed_time(i);
+ status_changed = true;
+ }
+ active_backend_count++;
}
- active_backend_count++;
}
if (status_changed)
[parent: b5c169822603]