From 0c96e42797dbe2918c909209abbaee4d2c985e38 Mon Sep 17 00:00:00 2001
From: Michael Meskes <meskes@postgresql.org>
Date: Wed, 8 Nov 2006 10:46:47 +0000
Subject: [PATCH] Applied patch by Peter Harris to free auto_mem structure on
 connect

---
 src/interfaces/ecpg/ChangeLog         | 4 ++++
 src/interfaces/ecpg/ecpglib/connect.c | 5 ++++-
 src/interfaces/ecpg/ecpglib/memory.c  | 4 ++--
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/interfaces/ecpg/ChangeLog b/src/interfaces/ecpg/ChangeLog
index 5e4524e791a..95605f475fd 100644
--- a/src/interfaces/ecpg/ChangeLog
+++ b/src/interfaces/ecpg/ChangeLog
@@ -2149,5 +2149,9 @@ Th 14. Sep 09:47:03 CEST 2006
 
 	- Completely removed complex tests.
 	- Added missing constuctor/destructor for interval and date.
+
+We 8. Nov 10:53:42 CET 2006
+
+	- Applied patch by Peter Harris to free auto_mem struct in ECPGconnect.
 	- Set ecpg library version to 5.2.
 	- Set ecpg version to 4.2.1.
diff --git a/src/interfaces/ecpg/ecpglib/connect.c b/src/interfaces/ecpg/ecpglib/connect.c
index 9636c91a363..374264cee09 100644
--- a/src/interfaces/ecpg/ecpglib/connect.c
+++ b/src/interfaces/ecpg/ecpglib/connect.c
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.36 2006/10/04 00:30:11 momjian Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.37 2006/11/08 10:46:47 meskes Exp $ */
 
 #define POSTGRES_ECPG_INTERNAL
 #include "postgres_fe.h"
@@ -277,6 +277,9 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
 
 	ECPGinit_sqlca(sqlca);
 
+	/* clear auto_mem structure because some error handling functions might access it */
+	ECPGclear_auto_mem();
+
 	if (INFORMIX_MODE(compat))
 	{
 		char	   *envname;
diff --git a/src/interfaces/ecpg/ecpglib/memory.c b/src/interfaces/ecpg/ecpglib/memory.c
index 49d3c29d1e3..3ee89a189a1 100644
--- a/src/interfaces/ecpg/ecpglib/memory.c
+++ b/src/interfaces/ecpg/ecpglib/memory.c
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/memory.c,v 1.7 2005/10/15 02:49:47 momjian Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/memory.c,v 1.8 2006/11/08 10:46:47 meskes Exp $ */
 
 #define POSTGRES_ECPG_INTERNAL
 #include "postgres_fe.h"
@@ -101,7 +101,7 @@ ECPGclear_auto_mem(void)
 {
 	struct auto_mem *am;
 
-	/* free just our own structure */
+	/* only free our own structure */
 	for (am = auto_allocs; am;)
 	{
 		struct auto_mem *act = am;
-- 
GitLab