postgres.git / summary / log / commit / refs
commit fc96c6942551dafa6cb2a6000cbc9b20643e5db3
Author: Andres Freund <andres@anarazel.de>
Date: Wed Jan 24 07:20:02 2018 +0000
Initialize unused ExprEvalStep fields.
ExecPushExprSlots didn't initialize ExprEvalStep's resvalue/resnull
steps as it didn't use them. That caused wrong valgrind warnings for
an upcoming patch, so zero-intialize.
Also zero-initialize all scratch ExprEvalStep's allocated on the
stack, to avoid issues with similar future omissions of non-critial
data.
src/backend/executor/execExpr.c | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/src/backend/executor/execExpr.c b/src/backend/executor/execExpr.c
index 883a29f0a7b..c6eb3ebacf8 100644
--- a/src/backend/executor/execExpr.c
+++ b/src/backend/executor/execExpr.c
@@ -118,7 +118,7 @@ ExprState *
ExecInitExpr(Expr *node, PlanState *parent)
{
ExprState *state;
- ExprEvalStep scratch;
+ ExprEvalStep scratch = {0};
/* Special case: NULL expression produces a NULL ExprState pointer */
if (node == NULL)
@@ -155,7 +155,7 @@ ExprState *
ExecInitExprWithParams(Expr *node, ParamListInfo ext_params)
{
ExprState *state;
- ExprEvalStep scratch;
+ ExprEvalStep scratch = {0};
/* Special case: NULL expression produces a NULL ExprState pointer */
if (node == NULL)
@@ -204,7 +204,7 @@ ExprState *
ExecInitQual(List *qual, PlanState *parent)
{
ExprState *state;
- ExprEvalStep scratch;
+ ExprEvalStep scratch = {0};
List *adjust_jumps = NIL;
ListCell *lc;
@@ -353,7 +353,7 @@ ExecBuildProjectionInfo(List *targetList,
{
ProjectionInfo *projInfo = makeNode(ProjectionInfo);
ExprState *state;
- ExprEvalStep scratch;
+ ExprEvalStep scratch = {0};
ListCell *lc;
projInfo->pi_exprContext = econtext;
@@ -638,7 +638,7 @@ static void
ExecInitExprRec(Expr *node, ExprState *state,
Datum *resv, bool *resnull)
{
- ExprEvalStep scratch;
+ ExprEvalStep scratch = {0};
/* Guard against stack overflow due to overly complex expressions */
check_stack_depth();
@@ -2273,7 +2273,10 @@ ExecInitExprSlots(ExprState *state, Node *node)
static void
ExecPushExprSlots(ExprState *state, LastAttnumInfo *info)
{
- ExprEvalStep scratch;
+ ExprEvalStep scratch = {0};
+
+ scratch.resvalue = NULL;
+ scratch.resnull = NULL;
/* Emit steps as needed */
if (info->last_inner > 0)
@@ -2659,7 +2662,7 @@ static void
ExecInitCoerceToDomain(ExprEvalStep *scratch, CoerceToDomain *ctest,
ExprState *state, Datum *resv, bool *resnull)
{
- ExprEvalStep scratch2;
+ ExprEvalStep scratch2 = {0};
DomainConstraintRef *constraint_ref;
Datum *domainval = NULL;
bool *domainnull = NULL;
@@ -2811,7 +2814,7 @@ ExecBuildAggTrans(AggState *aggstate, AggStatePerPhase phase,
{
ExprState *state = makeNode(ExprState);
PlanState *parent = &aggstate->ss.ps;
- ExprEvalStep scratch;
+ ExprEvalStep scratch = {0};
int transno = 0;
int setoff = 0;
bool isCombine = DO_AGGSPLIT_COMBINE(aggstate->aggsplit);
[parent: 1e1e599d6663]