if (count > 0) {
SV *out = POPs;
+ SvGETMAGIC(out);
if (SvOK(out)) {
status = SvIV(out);
}
LEAVE_with_name("call_filter_sub");
}
+ if (SvGMAGICAL(upstream)) {
+ mg_get(upstream);
+ if (upstream == buf_sv) mg_free(buf_sv);
+ }
if (SvIsCOW(upstream)) sv_force_normal(upstream);
if(!err && SvOK(upstream)) {
- got_p = SvPV(upstream, got_len);
+ got_p = SvPV_nomg(upstream, got_len);
if (umaxlen) {
if (got_len > umaxlen) {
prune_from = got_p + umaxlen;
if (SvUTF8(upstream)) {
SvUTF8_on(cache);
}
- SvCUR_set(upstream, got_len - cached_len);
+ if (SvPOK(upstream)) SvCUR_set(upstream, got_len - cached_len);
+ else
+ /* Cannot just use sv_setpvn, as that could free the buffer
+ before we have a chance to assign it. */
+ sv_usepvn(upstream, savepvn(got_p, got_len - cached_len),
+ got_len - cached_len);
*prune_from = 0;
/* Can't yet be EOF */
if (status == 0)
concatenate it then we get a warning about use of uninitialised value.
*/
if (!err && upstream != buf_sv &&
- (SvOK(upstream) || SvGMAGICAL(upstream))) {
- sv_catsv(buf_sv, upstream);
+ SvOK(upstream)) {
+ sv_catsv_nomg(buf_sv, upstream);
}
else if (SvOK(upstream)) (void)SvPV_force_nolen(buf_sv);