summaryrefslogtreecommitdiff
path: root/regcomp.c
diff options
context:
space:
mode:
authorKarl Williamson <public@khwilliamson.com>2012-01-05 13:27:35 -0700
committerKarl Williamson <public@khwilliamson.com>2012-01-13 09:58:38 -0700
commitc574ffb9e3a8b39aaba9060ba73c3b134fc572d3 (patch)
tree3a3d45cc066a670fea217ce5d0134756809dabf4 /regcomp.c
parentdcf8909ac1f19ef2c4b6354bfe982913360e9041 (diff)
downloadperl-c574ffb9e3a8b39aaba9060ba73c3b134fc572d3.tar.gz
regcomp.c: truncate long debug dump output
What an ANYOF node matches could theoretically be millions of characters long; This only outputs the first portion of very long ones.
Diffstat (limited to 'regcomp.c')
-rw-r--r--regcomp.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/regcomp.c b/regcomp.c
index 0c30210458..2d6bb7fbb9 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -11978,7 +11978,16 @@ Perl_regprop(pTHX_ const regexp *prog, SV *sv, const regnode *o)
}
while (*s) {
- if (*s == '\n')
+ if (*s == '\n') {
+
+ /* Truncate very long output */
+ if (s - origs > 256) {
+ Perl_sv_catpvf(aTHX_ sv,
+ "%.*s...",
+ (int) (s - origs - 1),
+ t);
+ goto out_dump;
+ }
*s = ' ';
}
else if (*s == '\t') {
@@ -11992,6 +12001,8 @@ Perl_regprop(pTHX_ const regexp *prog, SV *sv, const regnode *o)
sv_catpv(sv, t);
}
+ out_dump:
+
Safefree(origs);
}
SvREFCNT_dec(lv);