From 664553a778dd10a854c554d309c78de012813629 Mon Sep 17 00:00:00 2001 From: "Andrew M. Kuchling" Date: Sat, 23 Feb 2008 19:30:59 +0000 Subject: [PATCH] #1389051, #1092502: fix excessively large allocations when using read() on a socket --- Lib/socket.py | 2 +- Misc/NEWS | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Lib/socket.py b/Lib/socket.py index 0082e7656e..f79b28268d 100644 --- a/Lib/socket.py +++ b/Lib/socket.py @@ -305,7 +305,7 @@ class _fileobject(object): self._rbuf = "" while True: left = size - buf_len - recv_size = max(self._rbufsize, left) + recv_size = min(self._rbufsize, left) data = self._sock.recv(recv_size) if not data: break diff --git a/Misc/NEWS b/Misc/NEWS index 0926e7f009..e04cb3c924 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -18,6 +18,9 @@ Library - Bug #1389051: imaplib causes excessive memory fragmentation when reading large messages. +- Bug #1389051, 1092502: fix excessively large memory allocations when + calling .read() on a socket object wrapped with makefile(). + - Bug #1433694: minidom's .normalize() failed to set .nextSibling for last child element. -- 2.40.0