File tree 2 files changed +6
-9
lines changed
Misc/NEWS.d/next/Security
2 files changed +6
-9
lines changed Original file line number Diff line number Diff line change
1
+ Fixed a potential use-after-free in applications that call configuration
2
+ functions :c:func: `Py_SetPythonHome `, :c:func: `Py_SetProgramName ` or
3
+ (private) ``_Py_SetProgramFullPath `` multiple times.
Original file line number Diff line number Diff line change @@ -261,9 +261,7 @@ Py_SetPythonHome(const wchar_t *home)
261
261
_PyMem_SetDefaultAllocator (PYMEM_DOMAIN_RAW , & old_alloc );
262
262
263
263
PyMem_RawFree (_Py_path_config .home );
264
- if (has_value ) {
265
- _Py_path_config .home = _PyMem_RawWcsdup (home );
266
- }
264
+ _Py_path_config .home = has_value ? _PyMem_RawWcsdup (home ) : NULL ;
267
265
268
266
PyMem_SetAllocator (PYMEM_DOMAIN_RAW , & old_alloc );
269
267
@@ -282,9 +280,7 @@ Py_SetProgramName(const wchar_t *program_name)
282
280
_PyMem_SetDefaultAllocator (PYMEM_DOMAIN_RAW , & old_alloc );
283
281
284
282
PyMem_RawFree (_Py_path_config .program_name );
285
- if (has_value ) {
286
- _Py_path_config .program_name = _PyMem_RawWcsdup (program_name );
287
- }
283
+ _Py_path_config .program_name = has_value ? _PyMem_RawWcsdup (program_name ) : NULL ;
288
284
289
285
PyMem_SetAllocator (PYMEM_DOMAIN_RAW , & old_alloc );
290
286
@@ -302,9 +298,7 @@ _Py_SetProgramFullPath(const wchar_t *program_full_path)
302
298
_PyMem_SetDefaultAllocator (PYMEM_DOMAIN_RAW , & old_alloc );
303
299
304
300
PyMem_RawFree (_Py_path_config .program_full_path );
305
- if (has_value ) {
306
- _Py_path_config .program_full_path = _PyMem_RawWcsdup (program_full_path );
307
- }
301
+ _Py_path_config .program_full_path = has_value ? _PyMem_RawWcsdup (program_full_path ) : NULL ;
308
302
309
303
PyMem_SetAllocator (PYMEM_DOMAIN_RAW , & old_alloc );
310
304
You can’t perform that action at this time.
0 commit comments