… | |
… | |
121 | |
121 | |
122 | INLINE void |
122 | INLINE void |
123 | shrink (SV *sv) |
123 | shrink (SV *sv) |
124 | { |
124 | { |
125 | sv_utf8_downgrade (sv, 1); |
125 | sv_utf8_downgrade (sv, 1); |
|
|
126 | |
126 | if (SvLEN (sv) > SvCUR (sv) + 1) |
127 | if (SvLEN (sv) > SvCUR (sv) + 1) |
127 | { |
128 | { |
128 | #ifdef SvPV_shrink_to_cur |
129 | #ifdef SvPV_shrink_to_cur |
129 | SvPV_shrink_to_cur (sv); |
130 | SvPV_shrink_to_cur (sv); |
130 | #elif defined (SvPV_renew) |
131 | #elif defined (SvPV_renew) |
… | |
… | |
1413 | SV *sv; |
1414 | SV *sv; |
1414 | |
1415 | |
1415 | SvGETMAGIC (string); |
1416 | SvGETMAGIC (string); |
1416 | SvUPGRADE (string, SVt_PV); |
1417 | SvUPGRADE (string, SVt_PV); |
1417 | |
1418 | |
|
|
1419 | /* work around a bug in perl 5.10, which causes SvCUR to fail an |
|
|
1420 | * assertion with -DDEBUGGING, although SvCUR is documented to |
|
|
1421 | * return the xpv_cur field which certainly exists after upgrading. |
|
|
1422 | * according to nicholas clark, calling SvPOK fixes this. |
|
|
1423 | */ |
|
|
1424 | SvPOK (string); |
|
|
1425 | |
1418 | if (SvCUR (string) > json->max_size && json->max_size) |
1426 | if (SvCUR (string) > json->max_size && json->max_size) |
1419 | croak ("attempted decode of JSON text of %lu bytes size, but max_size is set to %lu", |
1427 | croak ("attempted decode of JSON text of %lu bytes size, but max_size is set to %lu", |
1420 | (unsigned long)SvCUR (string), (unsigned long)json->max_size); |
1428 | (unsigned long)SvCUR (string), (unsigned long)json->max_size); |
1421 | |
1429 | |
1422 | if (json->flags & F_UTF8) |
1430 | if (json->flags & F_UTF8) |