[PATCH][BUG FIX] Potential uninitialized vars used.

Started by Ranier Vilelaabout 6 years ago1 messages
#1Ranier Vilela
ranier_gyn@hotmail.com
1 attachment(s)

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

Attachments:

parse_expr.c.patchapplication/octet-stream; name=parse_expr.c.patchDownload
--- \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