Add missed bms_copy() in perform_pruning_combine_step

We were initializing a BMS to merely reference an existing one, which
would cause a double-free (and a crash) when the recursive algorithm
tried to intersect it with an empty one.  Fix it by creating a copy at
initialization time.

Reported-by: sqlsmith (by way of Andreas Seltenreich)
Author: Amit Langote
Discussion: https://postgr.es/m/87in923lyw.fsf@ansel.ydns.eu
This commit is contained in:
Alvaro Herrera 2018-04-09 10:54:28 -03:00
parent 2c19ea863a
commit 7ba6ee815d
1 changed files with 2 additions and 1 deletions

View File

@ -2923,7 +2923,8 @@ perform_pruning_combine_step(PartitionPruneContext *context,
if (firststep)
{
/* Copy step's result the first time. */
result->bound_offsets = step_result->bound_offsets;
result->bound_offsets =
bms_copy(step_result->bound_offsets);
result->scan_null = step_result->scan_null;
result->scan_default = step_result->scan_default;
firststep = false;