From d314616d128ba692aec434bd376bc40886f98f7b Mon Sep 17 00:00:00 2001
From: Michael Meskes <meskes@postgresql.org>
Date: Tue, 25 Jan 2005 12:51:31 +0000
Subject: [PATCH] Fixed segfault due to freeing a struct definition twice if it
 was a named struct used in a typedef.

---
 src/interfaces/ecpg/ChangeLog         | 5 +++++
 src/interfaces/ecpg/preproc/Makefile  | 6 +++---
 src/interfaces/ecpg/preproc/preproc.y | 6 +++---
 3 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/src/interfaces/ecpg/ChangeLog b/src/interfaces/ecpg/ChangeLog
index 1f8252731b..3e04df895c 100644
--- a/src/interfaces/ecpg/ChangeLog
+++ b/src/interfaces/ecpg/ChangeLog
@@ -1895,3 +1895,8 @@ Mon Jan 10 13:55:32 CET 2005
 	- Set compat library version to 1.2.
 	- Set ecpg library version to 4.2.
 
+Tue Jan 25 13:47:45 CET 2005
+
+	- Fixed segfault in preprocessor due to free a struct twice.
+	- Set ecpg version to 3.2.1.
+
diff --git a/src/interfaces/ecpg/preproc/Makefile b/src/interfaces/ecpg/preproc/Makefile
index d737574f06..a0599bcf5e 100644
--- a/src/interfaces/ecpg/preproc/Makefile
+++ b/src/interfaces/ecpg/preproc/Makefile
@@ -4,7 +4,7 @@
 #
 # Copyright (c) 1998-2005, PostgreSQL Global Development Group
 #
-# $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/Makefile,v 1.111 2005/01/18 05:00:28 momjian Exp $
+# $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/Makefile,v 1.112 2005/01/25 12:51:31 meskes Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -14,8 +14,8 @@ top_builddir = ../../../..
 include $(top_builddir)/src/Makefile.global
 
 MAJOR_VERSION=3
-MINOR_VERSION=3
-PATCHLEVEL=0
+MINOR_VERSION=2
+PATCHLEVEL=1
 
 override CPPFLAGS := -I$(srcdir)/../include -I$(srcdir) $(CPPFLAGS) \
 	-DMAJOR_VERSION=$(MAJOR_VERSION) \
diff --git a/src/interfaces/ecpg/preproc/preproc.y b/src/interfaces/ecpg/preproc/preproc.y
index 8ee348fc2f..6797787d8e 100644
--- a/src/interfaces/ecpg/preproc/preproc.y
+++ b/src/interfaces/ecpg/preproc/preproc.y
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.303 2005/01/10 12:58:30 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.304 2005/01/25 12:51:31 meskes Exp $ */
 
 /* Copyright comment */
 %{
@@ -4690,7 +4690,7 @@ type_declaration: S_TYPEDEF
 			this->type->type_index = length;    /* length of string */
 			this->type->type_sizeof = ECPGstruct_sizeof;
 			this->struct_member_list = ($3.type_enum == ECPGt_struct || $3.type_enum == ECPGt_union) ?
-				struct_member_list[struct_level] : NULL;
+				ECPGstruct_member_dup(struct_member_list[struct_level]) : NULL;
 
 			if ($3.type_enum != ECPGt_varchar &&
 			    $3.type_enum != ECPGt_char &&
@@ -5556,7 +5556,7 @@ ECPGTypedef: TYPE_P
 				this->type->type_index = length;	/* length of string */
 				this->type->type_sizeof = ECPGstruct_sizeof;
 				this->struct_member_list = ($5.type_enum == ECPGt_struct || $5.type_enum == ECPGt_union) ?
-					struct_member_list[struct_level] : NULL;
+					ECPGstruct_member_dup(struct_member_list[struct_level]) : NULL;
 
 				if ($5.type_enum != ECPGt_varchar &&
 					$5.type_enum != ECPGt_char &&