Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Check that the trusted/untrusted interpreters were created correctly …
…before loading any PBC
  • Loading branch information
leto committed Jul 8, 2010
1 parent 05e5684 commit f414dbf
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions plparrot.c
Expand Up @@ -107,17 +107,28 @@ void _PG_fini(void);
void
_PG_init(void)
{
elog(NOTICE,"_PG_init");
if (inited)
return;

Parrot_set_config_hash();
elog(NOTICE,"set_config_hash");
untrusted_interp = Parrot_new(NULL);

/* Must use the first created interp as the parent of subsequently created interps */
trusted_interp = Parrot_new(untrusted_interp);

//Parrot_set_trace(interp, PARROT_ALL_TRACE_FLAGS);
#ifdef HAS_PERL6
if (!trusted_interp) {
elog(ERROR,"Could not create a trusted Parrot interpreter!\n");
return;
}
if (!untrusted_interp) {
elog(ERROR,"Could not create an untrusted Parrot interpreter!\n");
return;
}

p6_interp = Parrot_new(trusted_interp);
p6u_interp = Parrot_new(untrusted_interp);
if (!p6_interp) {
Expand All @@ -132,14 +143,6 @@ _PG_init(void)
Parrot_load_bytecode(interp,create_string_const(PERL6PBC));
#endif

if (!trusted_interp) {
elog(ERROR,"Could not create a trusted Parrot interpreter!\n");
return;
}
if (!untrusted_interp) {
elog(ERROR,"Could not create an untrusted Parrot interpreter!\n");
return;
}
interp = trusted_interp;
plparrot_secure(interp);

Expand Down Expand Up @@ -399,7 +402,7 @@ plperl6_call_handler(PG_FUNCTION_ARGS)
{
Datum retval = 0;
TriggerData *tdata;

elog(NOTICE, "plperl6_call_handler");
interp = p6_interp;
if(!interp) {
elog(ERROR,"Invalid Parrot interpreter!");
Expand Down

0 comments on commit f414dbf

Please sign in to comment.