Mercurial > hg
changeset 40100:ca4a32d0a4d6
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.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Tue, 09 Oct 2018 07:46:01 +0900 |
parents | 994010b87534 |
children | 57500950f40e |
files | contrib/fuzz/manifest.cc |
diffstat | 1 files changed, 6 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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);