summaryrefslogtreecommitdiff
path: root/src/perl
diff options
context:
space:
mode:
authorDavid Leadbeater <dgl@dgl.cx>2014-06-19 03:12:05 +0100
committerDavid Leadbeater <dgl@dgl.cx>2014-06-27 11:08:01 +0100
commit211422cbe81570b1a70a6c4fe8a09b84cfa4f646 (patch)
treeb60608dacb9d0a88451d5118b14e05051bc75c68 /src/perl
parent9d0d4d9437649ed96381120e68a8d4035f6ded7e (diff)
downloadirssi-211422cbe81570b1a70a6c4fe8a09b84cfa4f646.zip
Switch to using G_DISCARD for call_pv
PUTBACK was being called even for the error path which didn't use the stack. Emitting the "script error" signal can involve running Perl code (Irssi:core::destroy) therefore the stack can be reallocated. This can result in the perl stack being corrupted because the local stack pointer is out of date (although as it's use of freed memory the crash is not always instant).
Diffstat (limited to 'src/perl')
-rw-r--r--src/perl/perl-core.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/perl/perl-core.c b/src/perl/perl-core.c
index 08d0738c..88726940 100644
--- a/src/perl/perl-core.c
+++ b/src/perl/perl-core.c
@@ -217,8 +217,6 @@ static int perl_script_eval(PERL_SCRIPT_REC *script)
{
dSP;
char *error;
- int retcount;
- SV *ret;
ENTER;
SAVETMPS;
@@ -229,10 +227,10 @@ static int perl_script_eval(PERL_SCRIPT_REC *script)
XPUSHs(sv_2mortal(new_pv(script->name)));
PUTBACK;
- retcount = perl_call_pv(script->path != NULL ?
- "Irssi::Core::eval_file" :
- "Irssi::Core::eval_data",
- G_EVAL|G_SCALAR);
+ perl_call_pv(script->path != NULL ?
+ "Irssi::Core::eval_file" :
+ "Irssi::Core::eval_data",
+ G_EVAL|G_DISCARD);
SPAGAIN;
error = NULL;
@@ -244,11 +242,8 @@ static int perl_script_eval(PERL_SCRIPT_REC *script)
signal_emit("script error", 2, script, error);
g_free(error);
}
- } else if (retcount > 0) {
- ret = POPs;
}
- PUTBACK;
FREETMPS;
LEAVE;