[PATCH][BUG FIX] Potential uninitialized vars used. - Mailing list pgsql-hackers

From Ranier Vilela
Subject [PATCH][BUG FIX] Potential uninitialized vars used.
Date
Msg-id MN2PR18MB2927B2E9D8A29761195FB5EFE3770@MN2PR18MB2927.namprd18.prod.outlook.com
Whole thread Raw
List pgsql-hackers
Hi,
Var TargetEntry *tle;
Have several paths where can it fail.

Can anyone check this bug fix?

--- \dll\postgresql-12.0\a\backend\parser\parse_expr.c    Mon Sep 30 17:06:55 2019
+++ parse_expr.c    Tue Nov 12 12:43:07 2019
@@ -349,6 +349,7 @@
                      errmsg("DEFAULT is not allowed in this context"),
                      parser_errposition(pstate,
                                         ((SetToDefault *) expr)->location)));
+            result = NULL;        /* keep compiler quiet */
             break;

             /*
@@ -1637,11 +1638,13 @@
             pstate->p_multiassign_exprs = lappend(pstate->p_multiassign_exprs,
                                                   tle);
         }
-        else
+        else {
             ereport(ERROR,
                     (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                      errmsg("source for a multiple-column UPDATE item must be a sub-SELECT or ROW() expression"),
                      parser_errposition(pstate, exprLocation(maref->source))));
+            return NULL;
+        }
     }
     else
     {
@@ -1653,6 +1656,10 @@
         Assert(pstate->p_multiassign_exprs != NIL);
         tle = (TargetEntry *) llast(pstate->p_multiassign_exprs);
     }
+    if (tle == NULL) {
+        elog(ERROR, "unexpected expr type in multiassign list");
+        return NULL;                /* keep compiler quiet */
+    }

     /*
      * Emit the appropriate output expression for the current column

Attachment

pgsql-hackers by date:

Previous
From: Daniel Gustafsson
Date:
Subject: Re: Option to dump foreign data in pg_dump
Next
From: Konstantin Knizhnik
Date:
Subject: Re: Built-in connection pooler