From 530975eff2661ba937253f72658d49f225ef4f84 Mon Sep 17 00:00:00 2001 From: Vadim Yanitskiy Date: Thu, 14 Jul 2022 17:53:42 +0700 Subject: [PATCH] SEDbgMuxApp: properly handle peer.recv() returning None In 2990cc14b86c68b6c75ef9740817ba75552b802a I introduced a regression, which affects the 'establish' command: if no data is received from a Data Provider during 500 ms, the application crashes: File "sedbgmux.py", line 151, in do_establish if f['MsgType'] != DbgMuxFrame.MsgType.ConnData: TypeError: 'NoneType' object is not subscriptable This is happening because peer.recv() is returning None. --- sedbgmux.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sedbgmux.py b/sedbgmux.py index 675e35b..470406f 100755 --- a/sedbgmux.py +++ b/sedbgmux.py @@ -147,7 +147,8 @@ class SEDbgMuxApp(cmd2.Cmd): # Read the messages while True: f = self.peer.recv() - + if f is None: + continue # No more data in the buffer if f['MsgType'] != DbgMuxFrame.MsgType.ConnData: log.warning('Unexpected frame: %s', f) self.peer.send(DbgMuxFrame.MsgType.Ack)