in reply to Re^3: XS Prepending space to an SVs PV
in thread XS Prepending space to an SVs PV

You have to check that there is still space free when the OOK flag is true and update the IV also:
... if (SvOOK( n ) && (SvIV(sv) > 0)) { /* If we've some reserve left use +it */ SvLEN_set( n, SvLEN( n ) +1 ); SvCUR_set( n, ++l ); SvPV_set( n, --a ); SvIVX(sv)--; } ...