From 8dd32ae7c1728796a60b2147c4b198ab09ae2676 Mon Sep 17 00:00:00 2001 From: Andy Green Date: Sat, 23 Apr 2016 09:36:18 +0800 Subject: [PATCH] http2 handle error path on ensure_user_space Signed-off-by: Andy Green --- lib/http2.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/http2.c b/lib/http2.c index 317b8dda..2f3ea01a 100644 --- a/lib/http2.c +++ b/lib/http2.c @@ -64,8 +64,7 @@ lws_create_server_child_wsi(struct lws_vhost *vhost, struct lws *parent_wsi, if (parent_wsi->u.http2.child_count + 1 == parent_wsi->u.http2.peer_settings.setting[ LWS_HTTP2_SETTINGS__MAX_CONCURRENT_STREAMS]) - return NULL; - + goto bail; lws_http2_init(&wsi->u.http2.peer_settings); lws_http2_init(&wsi->u.http2.my_settings); wsi->u.http2.stream_id = sid; @@ -83,12 +82,20 @@ lws_create_server_child_wsi(struct lws_vhost *vhost, struct lws *parent_wsi, wsi->mode = parent_wsi->mode; wsi->protocol = &vhost->protocols[0]; - lws_ensure_user_space(wsi); + if (lws_ensure_user_space(wsi)) + goto bail; lwsl_info("%s: %p new child %p, sid %d, user_space=%p\n", __func__, parent_wsi, wsi, sid, wsi->user_space); return wsi; + +bail: + vhost->protocols[0].callback(wsi, LWS_CALLBACK_WSI_DESTROY, + NULL, NULL, 0); + lws_free(wsi); + + return NULL; } int lws_remove_server_child_wsi(struct lws_context *context, struct lws *wsi)