Skip to content

Commit 1978d7f

Browse files
committed
Adjust recent PERL_SYS_INIT3 call to avoid platforms where it might fail, and to remove compilation warning. Backpatch the release 7.4
1 parent 52f0fc7 commit 1978d7f

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/pl/plperl/plperl.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**********************************************************************
22
* plperl.c - perl as a procedural language for PostgreSQL
33
*
4-
* $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.147 2009/06/04 15:59:55 adunstan Exp $
4+
* $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.148 2009/06/05 20:32:00 adunstan Exp $
55
*
66
**********************************************************************/
77

@@ -401,6 +401,8 @@ plperl_init_interp(void)
401401

402402
int nargs = 3;
403403

404+
char *dummy_perl_env[1] = { NULL };
405+
404406
#ifdef WIN32
405407

406408
/*
@@ -443,11 +445,19 @@ plperl_init_interp(void)
443445
save_time = loc ? pstrdup(loc) : NULL;
444446
#endif
445447

446-
447-
#ifdef PERL_SYS_INIT3
448+
/****
449+
* The perl API docs state that PERL_SYS_INIT3 should be called before
450+
* allocating interprters. Unfortunately, on some platforms this fails
451+
* in the Perl_do_taint() routine, which is called when the platform is
452+
* using the system's malloc() instead of perl's own. Other platforms,
453+
* notably Windows, fail if PERL_SYS_INIT3 is not called. So we call it
454+
* if it's available, unless perl is using the system malloc(), which is
455+
* true when MYMALLOC is set.
456+
*/
457+
#if defined(PERL_SYS_INIT3) && !defined(MYMALLOC)
448458
/* only call this the first time through, as per perlembed man page */
449459
if (interp_state == INTERP_NONE)
450-
PERL_SYS_INIT3(&nargs, (char ***) &embedding, NULL);
460+
PERL_SYS_INIT3(&nargs, (char ***) &embedding, (char***)&dummy_perl_env);
451461
#endif
452462

453463
plperl_held_interp = perl_alloc();

0 commit comments

Comments
 (0)