diff options
author | Brandon Stansbury <brandonrstansbury@gmail.com> | 2020-12-31 09:44:46 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-31 09:44:46 (GMT) |
commit | 9655434cca5dfbea97bf6d355aec028e840b289c (patch) | |
tree | d34ad2c972abd9059a5f260c70732b215c9f0766 /Lib/base64.py | |
parent | f421bfce80730cb0ff5cbe14727ac30cf0462eed (diff) | |
download | cpython-9655434cca5dfbea97bf6d355aec028e840b289c.zip cpython-9655434cca5dfbea97bf6d355aec028e840b289c.tar.gz cpython-9655434cca5dfbea97bf6d355aec028e840b289c.tar.bz2 |
bpo-39068: Fix race condition in base64 (GH-17627)
There was a race condition in base64 in lazy initialization of multiple globals.
Diffstat (limited to 'Lib/base64.py')
-rwxr-xr-x | Lib/base64.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Lib/base64.py b/Lib/base64.py index 539ad16..e1256ad 100755 --- a/Lib/base64.py +++ b/Lib/base64.py @@ -344,7 +344,7 @@ def a85encode(b, *, foldspaces=False, wrapcol=0, pad=False, adobe=False): 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 @@ def b85encode(b, pad=False): 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) |