Message292846
It is possible to get a core dump by using uninitialized _json objects.
$ ./python -c "import _json; _json.make_scanner.__new__(_json.make_scanner)('', 0)"
Segmentation fault (core dumped)
$ ./python -c "import _json; _json.make_encoder.__new__(_json.make_encoder)([0], 0)"
Segmentation fault (core dumped)
The cause is that make_scanner and make_encoder classes implement __new__ and __init__. The __new__ methods create uninitialized object, with NULLs pointers, the __init__ methods initialize them. Possible solutions are: 1) set fields to Py_None rather than NULL in __new__; 2) check every pointer for NULL before using; 3) just remove __init__ methods and make initialization in __new__ methods. Since the scanner and the encoder are not inheritable classes, the latter solution look the most preferable to me. |
|
Date |
User |
Action |
Args |
2017-05-03 06:41:50 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, rhettinger, bob.ippolito, ezio.melotti |
2017-05-03 06:41:50 | serhiy.storchaka | set | messageid: <1493793710.25.0.994343860918.issue30243@psf.upfronthosting.co.za> |
2017-05-03 06:41:50 | serhiy.storchaka | link | issue30243 messages |
2017-05-03 06:41:49 | serhiy.storchaka | create | |
|