aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2018-07-24 15:27:13 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2018-07-24 16:23:56 +0200
commita4fd4bd73154d759c52ab7b4400da4dfa4e4dd4f (patch)
tree2c766bf6b55d04b24bb0cac84a18e7d67db98d96
parent59d2f191917bb1552f7eb892c0e7e0333fdace43 (diff)
afb-export: Fix event handler of API
Change-Id: Ibadaf6f41e39cce398d33a2a2a73751d68dad34d Signed-off-by: José Bollo <jose.bollo@iot.bzh>
-rw-r--r--src/afb-export.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/afb-export.c b/src/afb-export.c
index 799ad73e..b40dd079 100644
--- a/src/afb-export.c
+++ b/src/afb-export.c
@@ -1149,7 +1149,7 @@ int afb_export_event_handler_add(
}
/* create the event */
- handler = malloc(strlen(pattern) + strlen(pattern));
+ handler = malloc(strlen(pattern) + sizeof * handler);
if (!handler) {
ERROR("[API %s] can't allocate event handler %s", export->api.apiname, pattern);
errno = ENOMEM;
@@ -1161,7 +1161,7 @@ int afb_export_event_handler_add(
handler->callback = callback;
handler->closure = closure;
strcpy(handler->pattern, pattern);
- export->event_handlers = handler;
+ *previous = handler;
return 0;
}