From 331695a4d9ca40864240aca721dc588a206ff395 Mon Sep 17 00:00:00 2001
From: Tom Lane <tgl@sss.pgh.pa.us>
Date: Sun, 26 May 2019 10:06:37 -0400
Subject: [PATCH] Fix thinko in new ECPG "PREPARE AS" code.

ecpg_register_prepared_stmt() is pretty obviously checking the wrong
variable while trying to detect malloc failure.  Error in commit
a1dc6ab46, spotted by Coverity.
---
 src/interfaces/ecpg/ecpglib/prepare.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/interfaces/ecpg/ecpglib/prepare.c b/src/interfaces/ecpg/ecpglib/prepare.c
index fa9d74b80d..0dcf736390 100644
--- a/src/interfaces/ecpg/ecpglib/prepare.c
+++ b/src/interfaces/ecpg/ecpglib/prepare.c
@@ -85,7 +85,7 @@ ecpg_register_prepared_stmt(struct statement *stmt)
 		return false;
 
 	prep_stmt = (struct statement *) ecpg_alloc(sizeof(struct statement), lineno);
-	if (!stmt)
+	if (!prep_stmt)
 	{
 		ecpg_free(this);
 		return false;
-- 
2.40.0