Skip to content

Commit a9742f1

Browse files
committed
Remove incorrect (and ill-advised anyway) pfree's in pg_convert_from and
pg_convert_to. Per bug #3866 from Andrew Gilligan.
1 parent ceb9360 commit a9742f1

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

src/backend/utils/mb/mbutils.c

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* (currently mule internal code (mic) is used)
55
* Tatsuo Ishii
66
*
7-
* $PostgreSQL: pgsql/src/backend/utils/mb/mbutils.c,v 1.68 2007/11/15 21:14:40 momjian Exp $
7+
* $PostgreSQL: pgsql/src/backend/utils/mb/mbutils.c,v 1.69 2008/01/09 23:43:54 tgl Exp $
88
*/
99
#include "postgres.h"
1010

@@ -301,20 +301,17 @@ pg_convert_to(PG_FUNCTION_ARGS)
301301
{
302302
Datum string = PG_GETARG_DATUM(0);
303303
Datum dest_encoding_name = PG_GETARG_DATUM(1);
304-
Datum src_encoding_name = DirectFunctionCall1(
305-
namein, CStringGetDatum(DatabaseEncoding->name));
304+
Datum src_encoding_name = DirectFunctionCall1(namein,
305+
CStringGetDatum(DatabaseEncoding->name));
306306
Datum result;
307307

308308
/*
309309
* pg_convert expects a bytea as its first argument. We're passing it a
310310
* text argument here, relying on the fact that they are both in fact
311311
* varlena types, and thus structurally identical.
312312
*/
313-
result = DirectFunctionCall3(
314-
pg_convert, string, src_encoding_name, dest_encoding_name);
315-
316-
/* free memory allocated by namein */
317-
pfree((void *) src_encoding_name);
313+
result = DirectFunctionCall3(pg_convert, string,
314+
src_encoding_name, dest_encoding_name);
318315

319316
PG_RETURN_BYTEA_P(result);
320317
}
@@ -329,15 +326,12 @@ pg_convert_from(PG_FUNCTION_ARGS)
329326
{
330327
Datum string = PG_GETARG_DATUM(0);
331328
Datum src_encoding_name = PG_GETARG_DATUM(1);
332-
Datum dest_encoding_name = DirectFunctionCall1(
333-
namein, CStringGetDatum(DatabaseEncoding->name));
329+
Datum dest_encoding_name = DirectFunctionCall1(namein,
330+
CStringGetDatum(DatabaseEncoding->name));
334331
Datum result;
335332

336-
result = DirectFunctionCall3(
337-
pg_convert, string, src_encoding_name, dest_encoding_name);
338-
339-
/* free memory allocated by namein */
340-
pfree((void *) src_encoding_name);
333+
result = DirectFunctionCall3(pg_convert, string,
334+
src_encoding_name, dest_encoding_name);
341335

342336
/*
343337
* pg_convert returns a bytea, which we in turn return as text, relying on

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy