Skip to content

Commit fc96c69

Browse files
committed
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.
1 parent 1e1e599 commit fc96c69

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/backend/executor/execExpr.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ ExprState *
118118
ExecInitExpr(Expr *node, PlanState *parent)
119119
{
120120
ExprState *state;
121-
ExprEvalStep scratch;
121+
ExprEvalStep scratch = {0};
122122

123123
/* Special case: NULL expression produces a NULL ExprState pointer */
124124
if (node == NULL)
@@ -155,7 +155,7 @@ ExprState *
155155
ExecInitExprWithParams(Expr *node, ParamListInfo ext_params)
156156
{
157157
ExprState *state;
158-
ExprEvalStep scratch;
158+
ExprEvalStep scratch = {0};
159159

160160
/* Special case: NULL expression produces a NULL ExprState pointer */
161161
if (node == NULL)
@@ -204,7 +204,7 @@ ExprState *
204204
ExecInitQual(List *qual, PlanState *parent)
205205
{
206206
ExprState *state;
207-
ExprEvalStep scratch;
207+
ExprEvalStep scratch = {0};
208208
List *adjust_jumps = NIL;
209209
ListCell *lc;
210210

@@ -353,7 +353,7 @@ ExecBuildProjectionInfo(List *targetList,
353353
{
354354
ProjectionInfo *projInfo = makeNode(ProjectionInfo);
355355
ExprState *state;
356-
ExprEvalStep scratch;
356+
ExprEvalStep scratch = {0};
357357
ListCell *lc;
358358

359359
projInfo->pi_exprContext = econtext;
@@ -638,7 +638,7 @@ static void
638638
ExecInitExprRec(Expr *node, ExprState *state,
639639
Datum *resv, bool *resnull)
640640
{
641-
ExprEvalStep scratch;
641+
ExprEvalStep scratch = {0};
642642

643643
/* Guard against stack overflow due to overly complex expressions */
644644
check_stack_depth();
@@ -2273,7 +2273,10 @@ ExecInitExprSlots(ExprState *state, Node *node)
22732273
static void
22742274
ExecPushExprSlots(ExprState *state, LastAttnumInfo *info)
22752275
{
2276-
ExprEvalStep scratch;
2276+
ExprEvalStep scratch = {0};
2277+
2278+
scratch.resvalue = NULL;
2279+
scratch.resnull = NULL;
22772280

22782281
/* Emit steps as needed */
22792282
if (info->last_inner > 0)
@@ -2659,7 +2662,7 @@ static void
26592662
ExecInitCoerceToDomain(ExprEvalStep *scratch, CoerceToDomain *ctest,
26602663
ExprState *state, Datum *resv, bool *resnull)
26612664
{
2662-
ExprEvalStep scratch2;
2665+
ExprEvalStep scratch2 = {0};
26632666
DomainConstraintRef *constraint_ref;
26642667
Datum *domainval = NULL;
26652668
bool *domainnull = NULL;
@@ -2811,7 +2814,7 @@ ExecBuildAggTrans(AggState *aggstate, AggStatePerPhase phase,
28112814
{
28122815
ExprState *state = makeNode(ExprState);
28132816
PlanState *parent = &aggstate->ss.ps;
2814-
ExprEvalStep scratch;
2817+
ExprEvalStep scratch = {0};
28152818
int transno = 0;
28162819
int setoff = 0;
28172820
bool isCombine = DO_AGGSPLIT_COMBINE(aggstate->aggsplit);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy