D4906: fuzzers: init Python in LLVMFuzzerInitialize and intentionally leak it
durin42 (Augie Fackler)
phabricator at mercurial-scm.org
Mon Oct 8 16:09:38 UTC 2018
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
This sidesteps leaks (or "leaks", I'm not sure) in CPython, and lets
our fuzzer work.
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D4906
AFFECTED FILES
contrib/fuzz/manifest.cc
CHANGE DETAILS
diff --git a/contrib/fuzz/manifest.cc b/contrib/fuzz/manifest.cc
--- a/contrib/fuzz/manifest.cc
+++ b/contrib/fuzz/manifest.cc
@@ -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.
}
}
To: durin42, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list