mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 05:23:03 +01:00
Fix a couple 'invalid read' problems found by Valgrind. Both could cause crashes, one could result in invalid nulls placement. Removed const*const*const stuff in couple places because things like that make code really hard to understand
This commit is contained in:
parent
e5a97ada47
commit
311d7b4b34
@ -2930,7 +2930,7 @@ static jrd_nod* copy(thread_db* tdbb,
|
||||
return node;
|
||||
|
||||
case nod_sort:
|
||||
args += args;
|
||||
args += 2 * args;
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -2958,7 +2958,7 @@ static jrd_nod* copy(thread_db* tdbb,
|
||||
// finish off sort
|
||||
|
||||
if (input->nod_type == nod_sort) {
|
||||
for (const jrd_nod* const* const end = arg1 + input->nod_count;
|
||||
for (jrd_nod** end = arg1 + input->nod_count * 2;
|
||||
arg1 < end; arg1++, arg2++)
|
||||
{
|
||||
*arg2 = *arg1;
|
||||
@ -4630,7 +4630,7 @@ static jrd_nod* pass2(thread_db* tdbb, CompilerScratch* csb, jrd_nod* const node
|
||||
case nod_sort:
|
||||
{
|
||||
jrd_nod** ptr = node->nod_arg;
|
||||
for (const jrd_nod* const* const end = ptr + node->nod_count;
|
||||
for (jrd_nod** end = ptr + node->nod_count;
|
||||
ptr < end; ptr++)
|
||||
{
|
||||
(*ptr)->nod_flags |= nod_value;
|
||||
|
@ -3923,7 +3923,7 @@ static RecordSource* gen_aggregate(thread_db* tdbb, OptimizerBlk* opt, jrd_nod*
|
||||
{
|
||||
/* generate a sort block which the optimizer will try to map to an index */
|
||||
|
||||
jrd_nod* aggregate = PAR_make_node(tdbb, 2);
|
||||
jrd_nod* aggregate = PAR_make_node(tdbb, 3);
|
||||
aggregate->nod_type = nod_sort;
|
||||
aggregate->nod_count = 1;
|
||||
aggregate->nod_arg[0] = agg_operator->nod_arg[e_asgn_from];
|
||||
@ -3931,6 +3931,9 @@ static RecordSource* gen_aggregate(thread_db* tdbb, OptimizerBlk* opt, jrd_nod*
|
||||
if (agg_operator->nod_type == nod_agg_max) {
|
||||
aggregate->nod_arg[1] = (jrd_nod*) TRUE;
|
||||
}
|
||||
/* 10-Aug-2004. Nickolay Samofatov
|
||||
Unneeded nulls seem to be skipped somehow. */
|
||||
aggregate->nod_arg[2] = (jrd_nod*) rse_nulls_default;
|
||||
rse->rse_aggregate = aggregate;
|
||||
}
|
||||
|
||||
@ -5522,15 +5525,18 @@ static bool gen_sort_merge(thread_db* tdbb, OptimizerBlk* opt, RiverStack& org_r
|
||||
continue;
|
||||
}
|
||||
stream_cnt += river1->riv_count;
|
||||
jrd_nod* sort = FB_NEW_RPT(*tdbb->tdbb_default, selected_classes.getCount() * 2) jrd_nod();
|
||||
jrd_nod* sort = FB_NEW_RPT(*tdbb->tdbb_default, selected_classes.getCount() * 3) jrd_nod();
|
||||
sort->nod_type = nod_sort;
|
||||
sort->nod_count = selected_classes.getCount();
|
||||
jrd_nod*** selected_class;
|
||||
for (selected_class = selected_classes.begin(), ptr = sort->nod_arg;
|
||||
selected_class < selected_classes.end(); selected_class++)
|
||||
{
|
||||
ptr[sort->nod_count] = (jrd_nod*) FALSE; // Ascending sort
|
||||
ptr[sort->nod_count * 2] = (jrd_nod*) rse_nulls_default; // Default nulls placement
|
||||
*ptr++ = (*selected_class)[river1->riv_number];
|
||||
}
|
||||
|
||||
RecordSource* rsb =
|
||||
gen_sort(tdbb, opt, &river1->riv_count, NULL, river1->riv_rsb, sort, false);
|
||||
*rsb_tail++ = rsb;
|
||||
|
Loading…
Reference in New Issue
Block a user