Author serhiy.storchaka
Recipients bob.ippolito, ezio.melotti, rhettinger, serhiy.storchaka
Date 2017-05-03.06:41:49
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
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:50serhiy.storchakasetrecipients: + serhiy.storchaka, rhettinger, bob.ippolito, ezio.melotti
2017-05-03 06:41:50serhiy.storchakasetmessageid: <>
2017-05-03 06:41:50serhiy.storchakalinkissue30243 messages
2017-05-03 06:41:49serhiy.storchakacreate