From 0811a9ebde4975d4e934cf4752376dd0db9bb7e4 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Fri, 7 Nov 2014 16:01:41 +1300 Subject: [PATCH] .flush can raise NetlibDisconnect. This fixes a traceback found in fuzzing. --- netlib/tcp.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/netlib/tcp.py b/netlib/tcp.py index 46c28cd95..6b7540aa0 100644 --- a/netlib/tcp.py +++ b/netlib/tcp.py @@ -253,7 +253,10 @@ class _Connection(object): # Closing the socket is not our task, therefore we don't call close then. if type(self.connection) != SSL.Connection: if not getattr(self.wfile, "closed", False): - self.wfile.flush() + try: + self.wfile.flush() + except NetLibDisconnect: + pass self.wfile.close() self.rfile.close()