mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
gh-141141: Make base64.b85decode() thread safe (GH-141149)
This commit is contained in:
parent
9a19900673
commit
a7bf27f7f5
2 changed files with 6 additions and 2 deletions
|
|
@ -462,9 +462,12 @@ def b85decode(b):
|
||||||
# Delay the initialization of tables to not waste memory
|
# Delay the initialization of tables to not waste memory
|
||||||
# if the function is never called
|
# if the function is never called
|
||||||
if _b85dec is None:
|
if _b85dec is None:
|
||||||
_b85dec = [None] * 256
|
# we don't assign to _b85dec directly to avoid issues when
|
||||||
|
# multiple threads call this function simultaneously
|
||||||
|
b85dec_tmp = [None] * 256
|
||||||
for i, c in enumerate(_b85alphabet):
|
for i, c in enumerate(_b85alphabet):
|
||||||
_b85dec[c] = i
|
b85dec_tmp[c] = i
|
||||||
|
_b85dec = b85dec_tmp
|
||||||
|
|
||||||
b = _bytes_from_decode_data(b)
|
b = _bytes_from_decode_data(b)
|
||||||
padding = (-len(b)) % 5
|
padding = (-len(b)) % 5
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
Fix a thread safety issue with :func:`base64.b85decode`. Contributed by Benel Tayar.
|
||||||
Loading…
Add table
Add a link
Reference in a new issue