Mercurial > hg
changeset 40089:3418f83c8874
fuzzers: init Python in LLVMFuzzerInitialize and intentionally leak it
This sidesteps leaks (or "leaks", I'm not sure) in CPython, and lets
our fuzzer work.
Differential Revision: https://phab.mercurial-scm.org/D4906
author | Augie Fackler <augie@google.com> |
---|---|
date | Mon, 08 Oct 2018 11:47:25 -0400 |
parents | 129bfc7ad2cc |
children | a66594c5fad4 |
files | contrib/fuzz/manifest.cc |
diffstat | 1 files changed, 1 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/contrib/fuzz/manifest.cc Mon Oct 08 11:42:06 2018 -0400 +++ b/contrib/fuzz/manifest.cc Mon Oct 08 11:47:25 2018 -0400 @@ -31,12 +31,12 @@ strncpy(cpypath, pypath.c_str(), pypath.size()); setenv("PYTHONPATH", cpypath, 1); Py_SetPythonHome(cpypath); + Py_InitializeEx(0); return 0; } int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { - Py_InitializeEx(0); initparsers(); PyObject *mtext = PyBytes_FromStringAndSize((const char *)Data, (Py_ssize_t)Size); @@ -69,7 +69,6 @@ Py_DECREF(code); Py_DECREF(locals); Py_DECREF(mtext); - Py_Finalize(); return 0; // Non-zero return values are reserved for future use. } }