pgpool2.git / summary / log / commit / refs

commit    cf095115ec32bdc8991452868c9f491d7e41cace
Author:   Tatsuo Ishii <ishii@postgresql.org>
Date:     Sun Nov 03 12:53:16 2013 +0000

    Fix memory leak when do_query() fails in timestamp rewriting.
    
    For this purpose free_select_result() is changed to accept NULL
    argument.  Per Coverity report "1111454, 1111455 Resource leak".


src/protocol/pool_process_query.c | 3 +++ src/rewrite/pool_timestamp.c | 2 ++ 2 files changed, 5 insertions(+) diff --git a/src/protocol/pool_process_query.c b/src/protocol/pool_process_query.c index aad73ca1d..eb73d224e 100644 --- a/src/protocol/pool_process_query.c +++ b/src/protocol/pool_process_query.c @@ -2312,6 +2312,9 @@ void free_select_result(POOL_SELECT_RESULT *result) int i, j; int index; + if (result == NULL) + return; + if (result->nullflags) free(result->nullflags); diff --git a/src/rewrite/pool_timestamp.c b/src/rewrite/pool_timestamp.c index 14346f264..c87498bfa 100644 --- a/src/rewrite/pool_timestamp.c +++ b/src/rewrite/pool_timestamp.c @@ -318,6 +318,7 @@ get_current_timestamp(POOL_CONNECTION_POOL *backend) if (status != POOL_CONTINUE) { pool_error("get_current_timestamp: do_query failed"); + free_select_result(res); return NULL; } @@ -869,6 +870,7 @@ static A_Const *makeStringConstFromQuery(POOL_CONNECTION_POOL *backend, char *ex if (status != POOL_CONTINUE) { pool_error("makeStringConstFromQuery: do_query failed"); + free_select_result(res); return NULL; } [parent: af11a6070183]