1
0
mirror of https://github.com/irssi/irssi.git synced 2024-12-04 14:46:39 -05:00

Merge pull request #1234 from ailin-nemui/fix/perlsignals

Copy Perl signal arguments prior to running callbacks
This commit is contained in:
ailin-nemui 2020-11-14 19:43:10 +01:00 committed by GitHub
commit f57dcfe90d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View File

@ -38,6 +38,7 @@ while :; do
;;
--lines)
lines+=("$2")
off_opts+=("$1" "$2")
shift 2
continue
;;

View File

@ -87,6 +87,7 @@ void perl_signal_args_to_c(void (*callback)(void *, int, void **), void *cb_arg,
GSList *v_gslist;
GList *v_glist;
} saved_args[SIGNAL_MAX_ARGUMENTS];
AV *aargs;
void *p[SIGNAL_MAX_ARGUMENTS];
PERL_SIGNAL_ARGS_REC *rec;
char *arglist[MAX_FORMAT_PARAMS];
@ -203,10 +204,13 @@ void perl_signal_args_to_c(void (*callback)(void *, int, void **), void *cb_arg,
p[n] = NULL;
}
/* make a copy of the stack now, since the callback might change it */
aargs = av_make(n_args, args);
callback(cb_arg, n_args, p);
for (n = 0; n < SIGNAL_MAX_ARGUMENTS && n < n_args && rec->args[n] != NULL; ++n) {
SV *arg = args[n];
SV *arg = *av_fetch(aargs, n, 0);
if (!SvOK(arg)) {
continue;
@ -245,6 +249,7 @@ void perl_signal_args_to_c(void (*callback)(void *, int, void **), void *cb_arg,
g_list_free(gl);
}
}
av_undef(aargs);
}
static void perl_call_signal(PERL_SCRIPT_REC *script, SV *func,