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.
--- 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);