summaryrefslogtreecommitdiffstats
path: root/Lib/base64.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2021-01-01 17:41:49 (GMT)
committerGitHub <noreply@github.com>2021-01-01 17:41:49 (GMT)
commitb863607d303a87e8680149361ac987328b35ca5f (patch)
tree90372aa6bb11456a8a3f5865bc1d3a795aebd23f /Lib/base64.py
parent187785e2fa2050156a6eda93fb2da31db13f07a6 (diff)
downloadcpython-b863607d303a87e8680149361ac987328b35ca5f.zip
cpython-b863607d303a87e8680149361ac987328b35ca5f.tar.gz
cpython-b863607d303a87e8680149361ac987328b35ca5f.tar.bz2
[3.8] bpo-39068: Fix race condition in base64 (GH-17627) (GH-24022)
There was a race condition in base64 in lazy initialization of multiple globals. (cherry picked from commit 9655434cca5dfbea97bf6d355aec028e840b289c) Co-authored-by: Brandon Stansbury <brandonrstansbury@gmail.com>
Diffstat (limited to 'Lib/base64.py')
-rwxr-xr-xLib/base64.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/Lib/base64.py b/Lib/base64.py
index 2e70223..5429766 100755
--- a/Lib/base64.py
+++ b/Lib/base64.py
@@ -320,7 +320,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]
@@ -428,7 +428,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)