From 0aede9b6508eedfebcc49cfe4742ff2ad92d1899 Mon Sep 17 00:00:00 2001 From: dimitr Date: Thu, 17 May 2012 09:04:23 +0000 Subject: [PATCH] Front-ported extra fixes for CORE-3557. --- src/dsql/ExprNodes.cpp | 6 ++++-- src/jrd/par.cpp | 9 ++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/dsql/ExprNodes.cpp b/src/dsql/ExprNodes.cpp index 31d3d416e3..9fdff8c2ef 100644 --- a/src/dsql/ExprNodes.cpp +++ b/src/dsql/ExprNodes.cpp @@ -4794,11 +4794,13 @@ DmlNode* FieldNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* cs if (is_column) { - jrd_rel* const temp_rel = csb->csb_rpt[stream].csb_relation; + const jrd_rel* const temp_rel = csb->csb_rpt[stream].csb_relation; if (temp_rel) { - if (id >= (int) temp_rel->rel_fields->count() || !(*temp_rel->rel_fields)[id]) + fb_assert(id >= 0); + + if (!temp_rel->rel_fields || id >= (int) temp_rel->rel_fields->count() || !(*temp_rel->rel_fields)[id]) { if (temp_rel->rel_flags & REL_system) return FB_NEW(pool) NullNode(pool); diff --git a/src/jrd/par.cpp b/src/jrd/par.cpp index 0aa5ed49a4..a5335fec10 100644 --- a/src/jrd/par.cpp +++ b/src/jrd/par.cpp @@ -623,14 +623,17 @@ ValueExprNode* PAR_make_field(thread_db* tdbb, CompilerScratch* csb, USHORT cont **************************************/ SET_TDBB(tdbb); + if (context >= csb->csb_rpt.getCount() || !(csb->csb_rpt[context].csb_flags & csb_used)) + return NULL; + const StreamType stream = csb->csb_rpt[context].csb_stream; jrd_rel* const relation = csb->csb_rpt[stream].csb_relation; jrd_prc* const procedure = csb->csb_rpt[stream].csb_procedure; - const SSHORT id = procedure ? - PAR_find_proc_field(procedure, base_field) : - MET_lookup_field(tdbb, relation, base_field); + const SSHORT id = + relation ? MET_lookup_field(tdbb, relation, base_field) : + procedure ? PAR_find_proc_field(procedure, base_field) : -1; if (id < 0) return NULL;