ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/CBOR-XS/XS.xs
(Generate patch)

Comparing CBOR-XS/XS.xs (file contents):
Revision 1.47 by root, Mon Apr 27 20:21:53 2015 UTC vs.
Revision 1.49 by root, Mon Feb 8 04:11:11 2016 UTC

584} 584}
585 585
586static SV * 586static SV *
587encode_cbor (SV *scalar, CBOR *cbor) 587encode_cbor (SV *scalar, CBOR *cbor)
588{ 588{
589 enc_t enc = { }; 589 enc_t enc = { 0 };
590 590
591 enc.cbor = *cbor; 591 enc.cbor = *cbor;
592 enc.sv = sv_2mortal (NEWSV (0, INIT_SIZE)); 592 enc.sv = sv_2mortal (NEWSV (0, INIT_SIZE));
593 enc.cur = SvPVX (enc.sv); 593 enc.cur = SvPVX (enc.sv);
594 enc.end = SvEND (enc.sv); 594 enc.end = SvEND (enc.sv);
749 if (ecb_expect_true ((U8)(*dec->cur - MAJOR_BYTES) <= LENGTH_EXT8)) 749 if (ecb_expect_true ((U8)(*dec->cur - MAJOR_BYTES) <= LENGTH_EXT8))
750 { 750 {
751 I32 len = decode_uint (dec); 751 I32 len = decode_uint (dec);
752 char *key = (char *)dec->cur; 752 char *key = (char *)dec->cur;
753 753
754 WANT (len);
754 dec->cur += len; 755 dec->cur += len;
755 756
756 hv_store (hv, key, len, decode_sv (dec), 0); 757 hv_store (hv, key, len, decode_sv (dec), 0);
757 758
758 return; 759 return;
759 } 760 }
760 else if (ecb_expect_true ((U8)(*dec->cur - MAJOR_TEXT) <= LENGTH_EXT8)) 761 else if (ecb_expect_true ((U8)(*dec->cur - MAJOR_TEXT) <= LENGTH_EXT8))
761 { 762 {
762 I32 len = decode_uint (dec); 763 I32 len = decode_uint (dec);
763 char *key = (char *)dec->cur; 764 char *key = (char *)dec->cur;
764 765
766 WANT (len);
765 dec->cur += len; 767 dec->cur += len;
766 768
767 if (ecb_expect_false (dec->cbor.flags & F_VALIDATE_UTF8)) 769 if (ecb_expect_false (dec->cbor.flags & F_VALIDATE_UTF8))
768 if (!is_utf8_string (key, len)) 770 if (!is_utf8_string (key, len))
769 ERR ("corrupted CBOR data (invalid UTF-8 in map key)"); 771 ERR ("corrupted CBOR data (invalid UTF-8 in map key)");
1163} 1165}
1164 1166
1165static SV * 1167static SV *
1166decode_cbor (SV *string, CBOR *cbor, char **offset_return) 1168decode_cbor (SV *string, CBOR *cbor, char **offset_return)
1167{ 1169{
1168 dec_t dec = { }; 1170 dec_t dec = { 0 };
1169 SV *sv; 1171 SV *sv;
1170 STRLEN len; 1172 STRLEN len;
1171 char *data = SvPVbyte (string, len); 1173 char *data = SvPVbyte (string, len);
1172 1174
1173 if (len > cbor->max_size && cbor->max_size) 1175 if (len > cbor->max_size && cbor->max_size)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines