@@ -412,17 +412,22 @@ int __lsan_is_turned_off(void) { return 1; }
412412
413413int LLVMFuzzerInitialize (int * argc , char * * * argv ) {
414414 PyConfig config ;
415- PyConfig_InitIsolatedConfig (& config );
415+ PyConfig_InitPythonConfig (& config );
416416 PyStatus status ;
417- wchar_t * wide_program_name = Py_DecodeLocale (* argv [0 ], NULL );
418- status = PyConfig_SetString (& config , & config .program_name ,
419- wide_program_name );
417+ status = PyConfig_SetBytesString (& config , & config .program_name , * argv [0 ]);
420418 if (PyStatus_Exception (status )) {
421- PyConfig_Clear (& config );
422- Py_ExitStatusException (status );
419+ goto fail ;
423420 }
424421
422+ status = Py_InitializeFromConfig (& config );
423+ if (PyStatus_Exception (status )) {
424+ goto fail ;
425+ }
426+ PyConfig_Clear (& config );
425427 return 0 ;
428+ fail :
429+ PyConfig_Clear (& config );
430+ Py_ExitStatusException (status );
426431}
427432
428433/* Fuzz test interface.
@@ -433,13 +438,6 @@ int LLVMFuzzerInitialize(int *argc, char ***argv) {
433438 (And we bitwise or when running multiple tests to verify that normally we
434439 only return 0.) */
435440int LLVMFuzzerTestOneInput (const uint8_t * data , size_t size ) {
436- if (!Py_IsInitialized ()) {
437- /* LLVMFuzzerTestOneInput is called repeatedly from the same process,
438- with no separate initialization phase, sadly, so we need to
439- initialize CPython ourselves on the first run. */
440- Py_InitializeEx (0 );
441- }
442-
443441 int rv = 0 ;
444442
445443#if !defined(_Py_FUZZ_ONE ) || defined(_Py_FUZZ_fuzz_builtin_float )
0 commit comments