From 7c52a36e23fb2eb6f1c1732e92d8c6544d7da226 Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Sun, 16 Nov 2008 19:25:24 +0100 Subject: [PATCH] Fix crash when a perl callback is called in "register" of another perl script --- src/plugins/scripts/perl/weechat-perl.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/plugins/scripts/perl/weechat-perl.c b/src/plugins/scripts/perl/weechat-perl.c index 684ed06fc..f24a77ba3 100644 --- a/src/plugins/scripts/perl/weechat-perl.c +++ b/src/plugins/scripts/perl/weechat-perl.c @@ -118,6 +118,7 @@ weechat_perl_exec (struct t_plugin_script *script, int *ret_i, mem_err, length; SV *ret_s; struct t_plugin_script *old_perl_current_script; + void *old_context; /* this code is placed here to conform ISO C90 */ dSP; @@ -128,6 +129,7 @@ weechat_perl_exec (struct t_plugin_script *script, #ifdef MULTIPLICITY (void) length; func = (char *) function; + old_context = PERL_GET_CONTEXT; PERL_SET_CONTEXT (script->interpreter); #else length = strlen (script->interpreter) + strlen (function) + 3; @@ -199,14 +201,10 @@ weechat_perl_exec (struct t_plugin_script *script, LEAVE; if (old_perl_current_script) - { perl_current_script = old_perl_current_script; #ifdef MULTIPLICITY - PERL_SET_CONTEXT (perl_current_script->interpreter); -#endif - } - -#ifndef MULTIPLICITY + PERL_SET_CONTEXT (old_context); +#else free (func); #endif