# HG changeset patch # User Augie Fackler # Date 1539013645 14400 # Node ID 3418f83c8874a93ac31688d360861c48386c5792 # Parent 129bfc7ad2ccac6775041ec7751d67b01f57c8cd 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 diff -r 129bfc7ad2cc -r 3418f83c8874 contrib/fuzz/manifest.cc --- 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. } }