fix bug on incoming event
authorJosé Bollo <jose.bollo@iot.bzh>
Fri, 21 Apr 2017 09:19:50 +0000 (11:19 +0200)
committerJosé Bollo <jose.bollo@iot.bzh>
Fri, 21 Apr 2017 09:19:50 +0000 (11:19 +0200)
Change-Id: I7678412374565fd5802b0312e5808e2645df3728
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
src/afb-wsj1.c

index 7a8e023..be961f5 100644 (file)
@@ -85,7 +85,10 @@ struct afb_wsj1 *afb_wsj1_create(struct sd_event *eloop, int fd, struct afb_wsj1
 {
        struct afb_wsj1 *result;
 
+       assert(eloop);
        assert(fd >= 0);
+       assert(itf);
+       assert(itf->on_call);
 
        result = calloc(1, sizeof * result);
        if (result == NULL)
@@ -337,7 +340,8 @@ static void wsj1_on_text(struct afb_wsj1 *wsj1, char *text, size_t size)
                free(call);
                break;
        case EVENT:
-               wsj1->itf->on_event(wsj1->closure, msg->event, msg);
+               if (wsj1->itf->on_event != NULL)
+                       wsj1->itf->on_event(wsj1->closure, msg->event, msg);
                break;
        }
        afb_wsj1_msg_unref(msg);