Skip to content
Snippets Groups Projects
Commit fb4809c7e4d7 authored by Brandon Stansbury's avatar Brandon Stansbury
Browse files

bpo-39068: Fix race condition in base64 (GH-17627)

There was a race condition in base64 in lazy initialization of multiple globals.
parent 1b2fa3a310a5
No related branches found
No related tags found
No related merge requests found
......@@ -344,7 +344,7 @@
global _a85chars, _a85chars2
# Delay the initialization of tables to not waste memory
# if the function is never called
if _a85chars is None:
if _a85chars2 is None:
_a85chars = [bytes((i,)) for i in range(33, 118)]
_a85chars2 = [(a + b) for a in _a85chars for b in _a85chars]
......@@ -452,7 +452,7 @@
global _b85chars, _b85chars2
# Delay the initialization of tables to not waste memory
# if the function is never called
if _b85chars is None:
if _b85chars2 is None:
_b85chars = [bytes((i,)) for i in _b85alphabet]
_b85chars2 = [(a + b) for a in _b85chars for b in _b85chars]
return _85encode(b, _b85chars, _b85chars2, pad)
......
......@@ -1659,6 +1659,7 @@
Frank Stajano
Joel Stanley
Kyle Stanley
Brandon Stansbury
Anthony Starks
David Steele
Oliver Steele
......
Fix initialization race condition in :func:`a85encode` and :func:`b85encode`
in :mod:`base64`. Patch by Brandon Stansbury.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment