This is an automated email from the ASF dual-hosted git repository.

ztao1987 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hawq.git

commit 83b45033531585aa889a195ab6bb2a007b17144a
Author: ztao1987 <zhenglin.ta...@gmail.com>
AuthorDate: Thu Nov 24 16:10:32 2022 +0800

    HAWQ-1851. Fix early free on savedSeqServerHost
---
 src/backend/cdb/motion/ic_common.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/backend/cdb/motion/ic_common.c 
b/src/backend/cdb/motion/ic_common.c
index b5a222ee4..4defd2d01 100644
--- a/src/backend/cdb/motion/ic_common.c
+++ b/src/backend/cdb/motion/ic_common.c
@@ -630,7 +630,7 @@ SetupSequenceServer(const char *host, int port)
                 * See MPP-10162: certain PL/PGSQL functions may call us 
multiple
                 * times without an intervening Teardown.
                 */
-               if (savedSeqServerHost != NULL)
+               if (savedSeqServerHost != NULL && savedSeqServerHost != host)
                {
                        free(savedSeqServerHost);
                        savedSeqServerHost = NULL;
@@ -641,7 +641,9 @@ SetupSequenceServer(const char *host, int port)
                 * Don't use MemoryContexts -- they make error handling
                 * difficult here.
                 */
-               savedSeqServerHost = strdup(host);
+               if (savedSeqServerHost != host) {
+                       savedSeqServerHost = strdup(host);
+               }
 
                if (savedSeqServerHost == NULL)
                {

Reply via email to