I wrote:
>In my tests with -Dmad, I'm still getting a test failure ("panic: input
>overflow") from t/op/incfilter.t. The underlying problem is the filter
>layer mishandling things when a filter function gives it a multiline
>string, so it generates an invalid SV state (strlen(SvPVX(PL_linestr))
>> SvCUR(PL_linestr)). This faulty state also occurs without -Dmad,
>and so doesn't appear to be Mad-related, it just doesn't in practice
>cause the test panic without -Dmad. I'm investigating this bug now.
It's fixed by the attached patch. Since the bug is an inconsistency
in the SV data structure, it can't be sensibly tested from Perl code,
so I'm at a loss for writing a test script. Hopefully that panic with
-Dmad is sufficient.
-zefram
Signed-off-by: H.Merijn Brand <h.m.brand@xs4all.nl>
int status = 0;
SV *upstream;
STRLEN got_len;
- const char *got_p = NULL;
- const char *prune_from = NULL;
+ char *got_p = NULL;
+ char *prune_from = NULL;
bool read_from_cache = FALSE;
STRLEN umaxlen;
prune_from = got_p + umaxlen;
}
} else {
- const char *const first_nl =
- (const char *)memchr(got_p, '\n', got_len);
+ char *const first_nl = (char *)memchr(got_p, '\n', got_len);
if (first_nl && first_nl + 1 < got_p + got_len) {
/* There's a second line here... */
prune_from = first_nl + 1;
SvUTF8_on(cache);
}
SvCUR_set(upstream, got_len - cached_len);
+ *prune_from = 0;
/* Can't yet be EOF */
if (status == 0)
status = 1;