… | |
… | |
1418 | |
1418 | |
1419 | /* work around a bug in perl 5.10, which causes SvCUR to fail an |
1419 | /* work around a bug in perl 5.10, which causes SvCUR to fail an |
1420 | * assertion with -DDEBUGGING, although SvCUR is documented to |
1420 | * assertion with -DDEBUGGING, although SvCUR is documented to |
1421 | * return the xpv_cur field which certainly exists after upgrading. |
1421 | * return the xpv_cur field which certainly exists after upgrading. |
1422 | * according to nicholas clark, calling SvPOK fixes this. |
1422 | * according to nicholas clark, calling SvPOK fixes this. |
|
|
1423 | * But it doesn't fix it, so try another workaround, call SvPV_nolen |
|
|
1424 | * and hope for the best. |
|
|
1425 | * Damnit, SvPV_nolen still trips over yet another assertion. This |
|
|
1426 | * assertion business is seriously broken, try yet another workaround |
|
|
1427 | * for the broken -DDEBUGGING. |
1423 | */ |
1428 | */ |
1424 | SvPOK (string); |
1429 | #ifdef DEBUGGING |
|
|
1430 | offset = SvOK (string) ? sv_len (string) : 0; |
|
|
1431 | #else |
|
|
1432 | offset = SvCUR (string); |
|
|
1433 | #endif |
1425 | |
1434 | |
1426 | if (SvCUR (string) > json->max_size && json->max_size) |
1435 | if (offset > json->max_size && json->max_size) |
1427 | croak ("attempted decode of JSON text of %lu bytes size, but max_size is set to %lu", |
1436 | croak ("attempted decode of JSON text of %lu bytes size, but max_size is set to %lu", |
1428 | (unsigned long)SvCUR (string), (unsigned long)json->max_size); |
1437 | (unsigned long)SvCUR (string), (unsigned long)json->max_size); |
1429 | |
1438 | |
1430 | if (json->flags & F_UTF8) |
1439 | if (json->flags & F_UTF8) |
1431 | sv_utf8_downgrade (string, 0); |
1440 | sv_utf8_downgrade (string, 0); |