Fix segfaut in streaming replication check process.
authorTatsuo Ishii <ishii@sraoss.co.jp>
Fri, 2 Aug 2019 04:03:13 +0000 (13:03 +0900)
committerTatsuo Ishii <ishii@sraoss.co.jp>
Fri, 2 Aug 2019 04:03:13 +0000 (13:03 +0900)
In case of failure of pg_stat_replication() call, the streaming
replication check process unconditionally tried to free the allocated
memory.  This should only be done when the call succeeds.

src/streaming_replication/pool_worker_child.c

index d1ecc3bb7661a22a0eeaaa4c21fbbfe986d45539..a297be2e8f1507fab5a8ac14228aebb97bd19253 100644 (file)
@@ -419,7 +419,8 @@ check_replication_time_lag(void)
                                }
                        }
                }
-               free_select_result(res_rep);
+               if (status == 0)
+                       free_select_result(res_rep);
        }
 
        for (i = 0; i < NUM_BACKENDS; i++)