2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-27 12:28:09 +00:00

Avoid calling fdopen on closed descriptor

This commit is contained in:
Eric Blundell 2018-03-20 15:42:31 -05:00
parent 5bc10b45a3
commit cd0e585d0d

View File

@ -2299,6 +2299,17 @@ class Client:
cdn_session.start() cdn_session.start()
try: try:
# cant fdopen the closed file descriptor from above
# which is closed due to the with statement in the branch just above
# make a new temp file to write to
try:
os.remove(file_name)
except OSError:
pass
fd, file_name = tempfile.mkstemp()
with os.fdopen(fd, "wb") as f: with os.fdopen(fd, "wb") as f:
while True: while True:
r2 = cdn_session.send( r2 = cdn_session.send(