fix SEGFLT when unhendled request
authorJosé Bollo <jose.bollo@iot.bzh>
Mon, 27 Feb 2017 08:31:33 +0000 (09:31 +0100)
committerJosé Bollo <jose.bollo@iot.bzh>
Mon, 27 Feb 2017 08:31:33 +0000 (09:31 +0100)
Change-Id: I34c657972111db843d0d9d26a1732b21ac519c57
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
src/afb-hsrv.c

index 91dff29..577ef85 100644 (file)
@@ -238,9 +238,11 @@ static void end_handler(void *cls, struct MHD_Connection *connection, void **rec
        struct afb_hreq *hreq;
 
        hreq = *recordreq;
-       if (hreq->upgrade)
-               MHD_suspend_connection (connection);
-       afb_hreq_unref(hreq);
+       if (hreq) {
+               if (hreq->upgrade)
+                       MHD_suspend_connection (connection);
+               afb_hreq_unref(hreq);
+       }
 }
 
 void run_micro_httpd(struct afb_hsrv *hsrv)