From a4fd4bd73154d759c52ab7b4400da4dfa4e4dd4f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Bollo?= Date: Tue, 24 Jul 2018 15:27:13 +0200 Subject: [PATCH] afb-export: Fix event handler of API MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Change-Id: Ibadaf6f41e39cce398d33a2a2a73751d68dad34d Signed-off-by: José Bollo --- src/afb-export.c | 4 ++-- 1 file 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; } -- 2.16.6