# HG changeset patch # User Yuya Nishihara # Date 1539038761 -32400 # Node ID ca4a32d0a4d613f5a68a47ba539930a903b9c9bc # Parent 994010b8753498b379384f9d75bfdecaffaab7ad fuzz: report error if Python code raised exception I think that's what we wanted to do, given the most of the code block is surrounded by try-except. 'lazymanifest(mdata)' is moved to the try block as it can fail. diff -r 994010b87534 -r ca4a32d0a4d6 contrib/fuzz/manifest.cc --- a/contrib/fuzz/manifest.cc Tue Oct 09 07:42:05 2018 +0900 +++ b/contrib/fuzz/manifest.cc Tue Oct 09 07:46:01 2018 +0900 @@ -47,8 +47,8 @@ PyCodeObject *code = (PyCodeObject *)Py_CompileString(R"py( from parsers import lazymanifest -lm = lazymanifest(mdata) try: + lm = lazymanifest(mdata) # iterate the whole thing, which causes the code to fully parse # every line in the manifest list(lm.iterentries()) @@ -65,7 +65,11 @@ # print e )py", "fuzzer", Py_file_input); - PyEval_EvalCode(code, globals, locals); + PyObject *res = PyEval_EvalCode(code, globals, locals); + if (!res) { + PyErr_Print(); + } + Py_XDECREF(res); Py_DECREF(code); Py_DECREF(locals); Py_DECREF(mtext);