From 0fc5ee87ff1625e87b1761b0a3553981c04ce2d8 Mon Sep 17 00:00:00 2001 From: Yutaka Hirano Date: Thu, 30 Sep 2021 23:42:38 +0900 Subject: [PATCH] [WebTransport] Check event type before using its properties The below code is problematic if self._session_stream_id == event.stream_id and\ isinstance(event, WebTransportStreamDataReceived): because it uses event's property before checking its type. This leads to errors when event without stream_id comes here. This change fixes that. --- tools/webtransport/h3/webtransport_h3_server.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/webtransport/h3/webtransport_h3_server.py b/tools/webtransport/h3/webtransport_h3_server.py index a48b28a03d223c..9feaf0873ab04b 100644 --- a/tools/webtransport/h3/webtransport_h3_server.py +++ b/tools/webtransport/h3/webtransport_h3_server.py @@ -109,8 +109,8 @@ def _h3_event_received(self, event: H3Event) -> None: self._send_error_response(event.stream_id, 400) self._session_stream_id = event.stream_id - if self._session_stream_id == event.stream_id and\ - isinstance(event, WebTransportStreamDataReceived): + if isinstance(event, WebTransportStreamDataReceived) and\ + self._session_stream_id == event.stream_id: self._session_stream_data += event.data if event.stream_ended: close_info = None