From 211422cbe81570b1a70a6c4fe8a09b84cfa4f646 Mon Sep 17 00:00:00 2001 From: David Leadbeater Date: Thu, 19 Jun 2014 03:12:05 +0100 Subject: [PATCH] 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). --- src/perl/perl-core.c | 13 ++++--------- 1 file 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;