From 46f5d4b1c47591ebadbfecba4942ea32b496d2bb Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Thu, 20 Feb 2014 21:30:05 +0900 Subject: [PATCH] examples: Check stream_data is null --- doc/sources/tutorial-server.rst | 5 ++++- examples/libevent-server.c | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/doc/sources/tutorial-server.rst b/doc/sources/tutorial-server.rst index 529f2c0e..bf06223e 100644 --- a/doc/sources/tutorial-server.rst +++ b/doc/sources/tutorial-server.rst @@ -462,7 +462,7 @@ is emitted via ``on_header_callback`` function, which is called after } stream_data = nghttp2_session_get_stream_user_data(session, frame->hd.stream_id); - if(stream_data->request_path) { + if(!stream_data || stream_data->request_path) { break; } if(namelen == sizeof(PATH) - 1 && memcmp(PATH, name, namelen) == 0) { @@ -580,6 +580,9 @@ is about to close:: http2_stream_data *stream_data; stream_data = nghttp2_session_get_stream_user_data(session, stream_id); + if(!stream_data) { + return 0; + } remove_stream(session_data, stream_data); delete_http2_stream_data(stream_data); return 0; diff --git a/examples/libevent-server.c b/examples/libevent-server.c index a929bf7c..58060b8b 100644 --- a/examples/libevent-server.c +++ b/examples/libevent-server.c @@ -410,7 +410,7 @@ static int on_header_callback(nghttp2_session *session, } stream_data = nghttp2_session_get_stream_user_data(session, frame->hd.stream_id); - if(stream_data->request_path) { + if(!stream_data || stream_data->request_path) { break; } if(namelen == sizeof(PATH) - 1 && memcmp(PATH, name, namelen) == 0) { @@ -529,6 +529,9 @@ static int on_stream_close_callback(nghttp2_session *session, http2_stream_data *stream_data; stream_data = nghttp2_session_get_stream_user_data(session, stream_id); + if(!stream_data) { + return 0; + } remove_stream(session_data, stream_data); delete_http2_stream_data(stream_data); return 0;