summaryrefslogtreecommitdiff
path: root/src/backend/executor/execParallel.c
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2017-12-20 17:21:55 -0500
committerRobert Haas <rhaas@postgresql.org>2017-12-20 17:26:50 -0500
commitf94eec490b2671399c102b89c9fa0311aea3a39f (patch)
treecd255050f6ea0e8487311db0e9198a5a8742cf30 /src/backend/executor/execParallel.c
parent7d3583ad9ae54b44119973a9d6d731c9cc74c86e (diff)
When passing query strings to workers, pass the terminating \0.
Otherwise, when the query string is read, we might trailing garbage beyond the end, unless there happens to be a \0 there by good luck. Report and patch by Thomas Munro. Reviewed by Rafia Sabih. Discussion: http://postgr.es/m/CAEepm=2SJs7X+_vx8QoDu8d1SMEOxtLhxxLNzZun_BvNkuNhrw@mail.gmail.com
Diffstat (limited to 'src/backend/executor/execParallel.c')
-rw-r--r--src/backend/executor/execParallel.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/backend/executor/execParallel.c b/src/backend/executor/execParallel.c
index 02b5aa517b5..604f4f5b613 100644
--- a/src/backend/executor/execParallel.c
+++ b/src/backend/executor/execParallel.c
@@ -597,7 +597,7 @@ ExecInitParallelPlan(PlanState *planstate, EState *estate,
/* Estimate space for query text. */
query_len = strlen(estate->es_sourceText);
- shm_toc_estimate_chunk(&pcxt->estimator, query_len);
+ shm_toc_estimate_chunk(&pcxt->estimator, query_len + 1);
shm_toc_estimate_keys(&pcxt->estimator, 1);
/* Estimate space for serialized PlannedStmt. */
@@ -672,8 +672,8 @@ ExecInitParallelPlan(PlanState *planstate, EState *estate,
shm_toc_insert(pcxt->toc, PARALLEL_KEY_EXECUTOR_FIXED, fpes);
/* Store query string */
- query_string = shm_toc_allocate(pcxt->toc, query_len);
- memcpy(query_string, estate->es_sourceText, query_len);
+ query_string = shm_toc_allocate(pcxt->toc, query_len + 1);
+ memcpy(query_string, estate->es_sourceText, query_len + 1);
shm_toc_insert(pcxt->toc, PARALLEL_KEY_QUERY_TEXT, query_string);
/* Store serialized PlannedStmt. */