Skip to content

Commit 538b101

Browse files
committed
Fix memory leak in SetClientEncoding().
1 parent fcbc87c commit 538b101

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/backend/utils/mb/mbutils.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* client encoding and server internal encoding.
44
* (currently mule internal code (mic) is used)
55
* Tatsuo Ishii
6-
* $Id: mbutils.c,v 1.30 2002/08/08 06:35:26 ishii Exp $
6+
* $Id: mbutils.c,v 1.31 2002/08/14 05:33:34 ishii Exp $
77
*/
88
#include "postgres.h"
99
#include "access/xact.h"
@@ -90,7 +90,21 @@ SetClientEncoding(int encoding, bool doit)
9090
if (IsTransactionState())
9191
{
9292
ClientEncoding = &pg_enc2name_tbl[encoding];
93+
94+
if(ToServerConvPorc != NULL)
95+
{
96+
if (ToServerConvPorc->fn_extra)
97+
pfree(ToServerConvPorc->fn_extra);
98+
pfree(ToServerConvPorc);
99+
}
93100
ToServerConvPorc = to_server;
101+
102+
if(ToClientConvPorc != NULL)
103+
{
104+
if (ToClientConvPorc->fn_extra)
105+
pfree(ToClientConvPorc->fn_extra);
106+
pfree(ToClientConvPorc);
107+
}
94108
ToClientConvPorc = to_client;
95109
}
96110
return 0;

0 commit comments

Comments
 (0)