@@ -412,17 +412,22 @@ int __lsan_is_turned_off(void) { return 1; }
412
412
413
413
int LLVMFuzzerInitialize (int * argc , char * * * argv ) {
414
414
PyConfig config ;
415
- PyConfig_InitIsolatedConfig (& config );
415
+ PyConfig_InitPythonConfig (& config );
416
416
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 ]);
420
418
if (PyStatus_Exception (status )) {
421
- PyConfig_Clear (& config );
422
- Py_ExitStatusException (status );
419
+ goto fail ;
423
420
}
424
421
422
+ status = Py_InitializeFromConfig (& config );
423
+ if (PyStatus_Exception (status )) {
424
+ goto fail ;
425
+ }
426
+ PyConfig_Clear (& config );
425
427
return 0 ;
428
+ fail :
429
+ PyConfig_Clear (& config );
430
+ Py_ExitStatusException (status );
426
431
}
427
432
428
433
/* Fuzz test interface.
@@ -433,13 +438,6 @@ int LLVMFuzzerInitialize(int *argc, char ***argv) {
433
438
(And we bitwise or when running multiple tests to verify that normally we
434
439
only return 0.) */
435
440
int 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
-
443
441
int rv = 0 ;
444
442
445
443
#if !defined(_Py_FUZZ_ONE ) || defined(_Py_FUZZ_fuzz_builtin_float )
0 commit comments