@@ -502,7 +502,6 @@ static int fuzz_elementtree_parsewhole(const char* data, size_t size) {
502502}
503503
504504#define MAX_PYCOMPILE_TEST_SIZE 16384
505- static char pycompile_scratch [MAX_PYCOMPILE_TEST_SIZE ];
506505
507506static const int start_vals [] = {Py_eval_input , Py_single_input , Py_file_input };
508507const size_t NUM_START_VALS = sizeof (start_vals ) / sizeof (start_vals [0 ]);
@@ -531,6 +530,8 @@ static int fuzz_pycompile(const char* data, size_t size) {
531530 unsigned char optimize_idx = (unsigned char ) data [1 ];
532531 int optimize = optimize_vals [optimize_idx % NUM_OPTIMIZE_VALS ];
533532
533+ char pycompile_scratch [MAX_PYCOMPILE_TEST_SIZE ];
534+
534535 // Create a NUL-terminated C string from the remaining input
535536 memcpy (pycompile_scratch , data + 2 , size - 2 );
536537 // Put a NUL terminator just after the copied data. (Space was reserved already.)
@@ -549,7 +550,13 @@ static int fuzz_pycompile(const char* data, size_t size) {
549550
550551 PyObject * result = Py_CompileStringExFlags (pycompile_scratch , "<fuzz input>" , start , flags , optimize );
551552 if (result == NULL ) {
552- /* compilation failed, most likely from a syntax error */
553+ /* Compilation failed, most likely from a syntax error. If it was a
554+ SystemError we abort. There's no non-bug reason to raise a
555+ SystemError. */
556+ if (PyErr_Occurred () && PyErr_ExceptionMatches (PyExc_SystemError )) {
557+ PyErr_Print ();
558+ abort ();
559+ }
553560 PyErr_Clear ();
554561 } else {
555562 Py_DECREF (result );
0 commit comments