--- CBOR-XS/XS.xs 2016/11/25 12:16:12 1.57 +++ CBOR-XS/XS.xs 2016/11/25 13:27:29 1.58 @@ -1068,6 +1068,8 @@ default: { + SV *tag_sv = newSVuv (tag); + sv = decode_sv (dec); dSP; @@ -1075,7 +1077,7 @@ SAVESTACK_POS (); PUSHMARK (SP); EXTEND (SP, 2); - PUSHs (newSVuv (tag)); + PUSHs (tag_sv); PUSHs (sv); PUTBACK; @@ -1084,19 +1086,21 @@ if (SvTRUE (ERRSV)) { + SvREFCNT_dec (tag_sv); FREETMPS; LEAVE; ERR (SvPVutf8_nolen (sv_2mortal (SvREFCNT_inc (ERRSV)))); } if (count) { + SvREFCNT_dec (tag_sv); SvREFCNT_dec (sv); sv = SvREFCNT_inc (POPs); } else { AV *av = newAV (); - av_push (av, newSVuv (tag)); + av_push (av, tag_sv); av_push (av, sv); HV *tagged_stash = !CBOR_SLOW || cbor_tagged_stash @@ -1235,7 +1239,7 @@ { if (dec.shareable) { - // need to break cyclic links, which whould all be in shareable + // need to break cyclic links, which would all be in shareable int i; SV **svp;