Commit a9742f12 authored by Tom Lane's avatar Tom Lane

Remove incorrect (and ill-advised anyway) pfree's in pg_convert_from and

pg_convert_to.  Per bug #3866 from Andrew Gilligan.
parent ceb93600
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* (currently mule internal code (mic) is used) * (currently mule internal code (mic) is used)
* Tatsuo Ishii * Tatsuo Ishii
* *
* $PostgreSQL: pgsql/src/backend/utils/mb/mbutils.c,v 1.68 2007/11/15 21:14:40 momjian Exp $ * $PostgreSQL: pgsql/src/backend/utils/mb/mbutils.c,v 1.69 2008/01/09 23:43:54 tgl Exp $
*/ */
#include "postgres.h" #include "postgres.h"
...@@ -301,8 +301,8 @@ pg_convert_to(PG_FUNCTION_ARGS) ...@@ -301,8 +301,8 @@ pg_convert_to(PG_FUNCTION_ARGS)
{ {
Datum string = PG_GETARG_DATUM(0); Datum string = PG_GETARG_DATUM(0);
Datum dest_encoding_name = PG_GETARG_DATUM(1); Datum dest_encoding_name = PG_GETARG_DATUM(1);
Datum src_encoding_name = DirectFunctionCall1( Datum src_encoding_name = DirectFunctionCall1(namein,
namein, CStringGetDatum(DatabaseEncoding->name)); CStringGetDatum(DatabaseEncoding->name));
Datum result; Datum result;
/* /*
...@@ -310,11 +310,8 @@ pg_convert_to(PG_FUNCTION_ARGS) ...@@ -310,11 +310,8 @@ pg_convert_to(PG_FUNCTION_ARGS)
* text argument here, relying on the fact that they are both in fact * text argument here, relying on the fact that they are both in fact
* varlena types, and thus structurally identical. * varlena types, and thus structurally identical.
*/ */
result = DirectFunctionCall3( result = DirectFunctionCall3(pg_convert, string,
pg_convert, string, src_encoding_name, dest_encoding_name); src_encoding_name, dest_encoding_name);
/* free memory allocated by namein */
pfree((void *) src_encoding_name);
PG_RETURN_BYTEA_P(result); PG_RETURN_BYTEA_P(result);
} }
...@@ -329,15 +326,12 @@ pg_convert_from(PG_FUNCTION_ARGS) ...@@ -329,15 +326,12 @@ pg_convert_from(PG_FUNCTION_ARGS)
{ {
Datum string = PG_GETARG_DATUM(0); Datum string = PG_GETARG_DATUM(0);
Datum src_encoding_name = PG_GETARG_DATUM(1); Datum src_encoding_name = PG_GETARG_DATUM(1);
Datum dest_encoding_name = DirectFunctionCall1( Datum dest_encoding_name = DirectFunctionCall1(namein,
namein, CStringGetDatum(DatabaseEncoding->name)); CStringGetDatum(DatabaseEncoding->name));
Datum result; Datum result;
result = DirectFunctionCall3( result = DirectFunctionCall3(pg_convert, string,
pg_convert, string, src_encoding_name, dest_encoding_name); src_encoding_name, dest_encoding_name);
/* free memory allocated by namein */
pfree((void *) src_encoding_name);
/* /*
* pg_convert returns a bytea, which we in turn return as text, relying on * pg_convert returns a bytea, which we in turn return as text, relying on
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment