1
0
mirror of https://github.com/irssi/irssi.git synced 2025-02-02 15:08:01 -05:00

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).
This commit is contained in:
David Leadbeater 2014-06-19 03:12:05 +01:00
parent 9d0d4d9437
commit 211422cbe8

View File

@ -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 ?
perl_call_pv(script->path != NULL ?
"Irssi::Core::eval_file" :
"Irssi::Core::eval_data",
G_EVAL|G_SCALAR);
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;