From 223b1d8f9bbcb1608a223cf74fabfbd5f475fdce Mon Sep 17 00:00:00 2001 From: totaj Date: Sat, 25 Mar 2023 11:03:30 +0800 Subject: [PATCH] Fix heap-use-after-free. --- src/gausskernel/runtime/executor/nodeHashjoin.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/gausskernel/runtime/executor/nodeHashjoin.cpp b/src/gausskernel/runtime/executor/nodeHashjoin.cpp index 51e49472e6..c48a5e2117 100755 --- a/src/gausskernel/runtime/executor/nodeHashjoin.cpp +++ b/src/gausskernel/runtime/executor/nodeHashjoin.cpp @@ -1141,6 +1141,12 @@ void ExecEarlyFreeHashJoin(HashJoinState* node) if (node->hj_HashTable) { ExecHashTableDestroy(node->hj_HashTable); node->hj_HashTable = NULL; + /* + * HashState.hashtable also point to hj_HashTable(check ExecHashJoin), + * so set it to null directly to avoid heap-use-after-free + */ + HashState* hash_state = (HashState*)innerPlanState(node); + hash_state->hashtable = NULL; } /* -- Gitee