From 08bfb6709dd6612a377c29bbe14e6e9bc12947f4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Wed, 9 Nov 2016 14:17:30 -0500 Subject: [PATCH] Validate notification type before casting MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérémie Galarneau --- lib/plugin-system/notification/event.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/plugin-system/notification/event.c b/lib/plugin-system/notification/event.c index 9163cb0cf..9d99a0d69 100644 --- a/lib/plugin-system/notification/event.c +++ b/lib/plugin-system/notification/event.c @@ -58,9 +58,16 @@ error: struct bt_ctf_event *bt_notification_event_get_event( struct bt_notification *notification) { + struct bt_ctf_event *event = NULL; struct bt_notification_event *event_notification; + if (bt_notification_get_type(notification) != + BT_NOTIFICATION_TYPE_EVENT) { + goto end; + } event_notification = container_of(notification, struct bt_notification_event, parent); - return bt_get(event_notification->event); + event = bt_get(event_notification->event); +end: + return event; } -- 2.34.1