Fix the failover() so that it does not access out of array.
authorTatsuo Ishii <ishii@sraoss.co.jp>
Wed, 17 Jul 2019 07:51:31 +0000 (16:51 +0900)
committerTatsuo Ishii <ishii@sraoss.co.jp>
Fri, 19 Jul 2019 07:45:11 +0000 (16:45 +0900)
Per Coverity.

src/main/pgpool_main.c

index 3e0fe52f211570af33097c10717913cf74797faf..15d273949a4d51b99a4ff9f540b0bc16633d0fef 100644 (file)
@@ -1783,6 +1783,7 @@ static void failover(void)
                        {
                                /* only if the failover is against the current primary */
                                if (((reqkind == NODE_DOWN_REQUEST) &&
+                                        Req_info->primary_node_id >= 0 &&
                                         (nodes[Req_info->primary_node_id])) ||
                                        (node_id >= 0 && (reqkind == PROMOTE_NODE_REQUEST) &&
                                         (VALID_BACKEND(node_id))))