From ea904f8dc94f2efc7aa0bf532400502a13dcb2c1 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Sat, 24 Nov 2001 01:31:49 +0000 Subject: [PATCH] Irssi::printformat() crashed if the registered format contained $0- etc. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2137 dbcabf3a-b0e7-0310-adc4-f8d773084564 --- src/perl/ui/Themes.xs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/perl/ui/Themes.xs b/src/perl/ui/Themes.xs index cae50865..99f1fc78 100644 --- a/src/perl/ui/Themes.xs +++ b/src/perl/ui/Themes.xs @@ -122,13 +122,13 @@ printformat(level, format, ...) PREINIT: STRLEN n_a; TEXT_DEST_REC dest; - char *arglist[MAX_FORMAT_PARAMS]; + char *arglist[MAX_FORMAT_PARAMS+1]; int n; CODE: format_create_dest(&dest, NULL, NULL, level, NULL); memset(arglist, 0, sizeof(arglist)); - for (n = 2; n < 2+MAX_FORMAT_PARAMS; n++) { - arglist[n-2] = n < items ? SvPV(ST(n), n_a) : ""; + for (n = 2; n < items && n < MAX_FORMAT_PARAMS-2; n++) { + arglist[n-2] = SvPV(ST(n), n_a); } printformat_perl(&dest, format, arglist); @@ -146,13 +146,13 @@ printformat(server, target, level, format, ...) PREINIT: STRLEN n_a; TEXT_DEST_REC dest; - char *arglist[MAX_FORMAT_PARAMS]; + char *arglist[MAX_FORMAT_PARAMS+1]; int n; CODE: format_create_dest(&dest, server, target, level, NULL); memset(arglist, 0, sizeof(arglist)); - for (n = 4; n < 4+MAX_FORMAT_PARAMS; n++) { - arglist[n-4] = n < items ? SvPV(ST(n), n_a) : ""; + for (n = 4; n < items && n < MAX_FORMAT_PARAMS-4; n++) { + arglist[n-4] = SvPV(ST(n), n_a); } printformat_perl(&dest, format, arglist); @@ -169,13 +169,13 @@ printformat(window, level, format, ...) PREINIT: STRLEN n_a; TEXT_DEST_REC dest; - char *arglist[MAX_FORMAT_PARAMS]; + char *arglist[MAX_FORMAT_PARAMS+1]; int n; CODE: format_create_dest(&dest, NULL, NULL, level, window); memset(arglist, 0, sizeof(arglist)); - for (n = 3; n < 3+MAX_FORMAT_PARAMS; n++) { - arglist[n-3] = n < items ? SvPV(ST(n), n_a) : ""; + for (n = 3; n < items && n < MAX_FORMAT_PARAMS-3; n++) { + arglist[n-3] = SvPV(ST(n), n_a); } printformat_perl(&dest, format, arglist); @@ -192,13 +192,13 @@ printformat(item, level, format, ...) PREINIT: STRLEN n_a; TEXT_DEST_REC dest; - char *arglist[MAX_FORMAT_PARAMS]; + char *arglist[MAX_FORMAT_PARAMS+1]; int n; CODE: format_create_dest(&dest, item->server, item->name, level, NULL); memset(arglist, 0, sizeof(arglist)); - for (n = 3; n < 3+MAX_FORMAT_PARAMS; n++) { - arglist[n-3] = n < items ? SvPV(ST(n), n_a) : ""; + for (n = 3; n < items && n < MAX_FORMAT_PARAMS-3; n++) { + arglist[n-3] = SvPV(ST(n), n_a); } printformat_perl(&dest, format, arglist);