From ca10339e6ebd897edff99b03d84bc9faea6a37fd Mon Sep 17 00:00:00 2001 From: Jongmin Lee Date: Fri, 20 Apr 2018 08:31:21 +0900 Subject: [PATCH] Add exception handling in case of memory allocation fails Change-Id: I05bdd0d15f8c71330f79e6939e0c742f3a165d96 --- src/e_dispatch_key_event.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/e_dispatch_key_event.c b/src/e_dispatch_key_event.c index 953fd97..ff785be 100644 --- a/src/e_dispatch_key_event.c +++ b/src/e_dispatch_key_event.c @@ -112,6 +112,9 @@ _e_dispatch_key_event(KeyEventInfo kei, Eldbus_Connection *conn, const Eldbus_Me return error_msg; KeyEventData *ked = (KeyEventData *)malloc(sizeof(KeyEventData)); + if (!ked) + return eldbus_message_error_new(msg, "org.freedesktop.DBus.Error.Failed", "Malloc error."); + ked->info.keyname = strdup(kei.keyname); ked->info.multiplicity = kei.multiplicity; ked->info.hold_time = kei.hold_time; -- 2.7.4