pgpool2.git / summary / log / commit / refs
commit 97ffd1a6aa498e60fba92aed95e3d3145b8ae4c5
Author: Tatsuo Ishii <ishii@sraoss.co.jp>
Date: Thu Oct 04 22:56:57 2018 +0000
Fix some coverity warnings.
CommandComplete.c: fix memory leak
pool_memqcache.c: fix access to already freed data
src/protocol/CommandComplete.c | 4 ++++
src/query_cache/pool_memqcache.c | 3 ++-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/protocol/CommandComplete.c b/src/protocol/CommandComplete.c
index 81bd5287b..5adee00ab 100644
--- a/src/protocol/CommandComplete.c
+++ b/src/protocol/CommandComplete.c
@@ -75,6 +75,8 @@ CommandComplete(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend, bool
*/
if (SL_MODE && pool_is_doing_extended_query_message())
{
+ p1 = NULL;
+
for (i = 0; i < NUM_BACKENDS; i++)
{
if (VALID_BACKEND(i))
@@ -91,6 +93,8 @@ CommandComplete(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend, bool
p = pool_read2(con, len);
if (p == NULL)
return POOL_END;
+ if (p1 != NULL)
+ pfree(p1);
p1 = palloc(len);
memcpy(p1, p, len);
diff --git a/src/query_cache/pool_memqcache.c b/src/query_cache/pool_memqcache.c
index 1d8745b6d..a271ddc3d 100644
--- a/src/query_cache/pool_memqcache.c
+++ b/src/query_cache/pool_memqcache.c
@@ -2889,10 +2889,11 @@ pool_discard_temp_query_cache(POOL_TEMP_QUERY_CACHE * temp_cache)
pool_discard_buffer(temp_cache->buffer);
if (temp_cache->oids)
pool_discard_buffer(temp_cache->oids);
- pfree(temp_cache);
ereport(DEBUG1,
(errmsg("pool_discard_temp_query_cache: cache discarded: %p", temp_cache)));
+
+ pfree(temp_cache);
}
/*
[parent: 019960ae0a80]