aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor/nodeHash.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2018-02-02 18:32:05 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2018-02-02 18:32:05 -0500
commitd59ff4ab3111f20054425d82dab1393101dcfe8e (patch)
treed75ba05547d48b26998d6b875ee77f69afcecb13 /src/backend/executor/nodeHash.c
parent957ff087c822c95f63df956e1a91c15614ecb2b4 (diff)
downloadpostgresql-d59ff4ab3111f20054425d82dab1393101dcfe8e.tar.gz
postgresql-d59ff4ab3111f20054425d82dab1393101dcfe8e.zip
Fix another instance of unsafe coding for shm_toc_lookup failure.
One or another author of commit 5bcf389ec seems to have thought that computing an offset from a NULL pointer would yield another NULL pointer. There may possibly be architectures where that works, but common machines don't work like that. Per a quick code review of places calling shm_toc_lookup and not using noError = false.
Diffstat (limited to 'src/backend/executor/nodeHash.c')
-rw-r--r--src/backend/executor/nodeHash.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/backend/executor/nodeHash.c b/src/backend/executor/nodeHash.c
index c26b8ea44e3..70553b8fdf9 100644
--- a/src/backend/executor/nodeHash.c
+++ b/src/backend/executor/nodeHash.c
@@ -2582,9 +2582,13 @@ ExecHashInitializeWorker(HashState *node, ParallelWorkerContext *pwcxt)
{
SharedHashInfo *shared_info;
+ /* might not be there ... */
shared_info = (SharedHashInfo *)
shm_toc_lookup(pwcxt->toc, node->ps.plan->plan_node_id, true);
- node->hinstrument = &shared_info->hinstrument[ParallelWorkerNumber];
+ if (shared_info)
+ node->hinstrument = &shared_info->hinstrument[ParallelWorkerNumber];
+ else
+ node->hinstrument = NULL;
}
/*