From 2685899d595cc2827de99a1aaa477e94019e31f6 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Wed, 5 Aug 2020 11:15:03 +0900 Subject: [PATCH] Fix issue detected by static analysis tool Pointer 'attr' returned from function 'calloc' at ise-dbus.cpp:107 may be null, and it is dereferenced at ise-dbus.cpp:108. Change-Id: Ic32b7debe0ec1bae7f893f42a6dfbfa019762ef2 Signed-off-by: Jihoon Kim --- src/ise-dbus.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/ise-dbus.cpp b/src/ise-dbus.cpp index 6ea44ae..e0dd1ee 100644 --- a/src/ise-dbus.cpp +++ b/src/ise-dbus.cpp @@ -105,11 +105,13 @@ static void _handle_engine_loader_cb(GDBusConnection *connection, while (g_variant_iter_loop (attr_iter, "(v)", &iter_body)) { g_variant_get(iter_body, "(uuuu)", &start, &length, &type, &value); attr = (ime_preedit_attribute *)calloc(1, sizeof(ime_preedit_attribute)); - attr->start = start; - attr->length = length; - attr->type = (ime_attribute_type)type; - attr->value = value; - list = eina_list_append(list, attr); + if (attr) { + attr->start = start; + attr->length = length; + attr->type = (ime_attribute_type)type; + attr->value = value; + list = eina_list_append(list, attr); + } } int ret = ime_update_preedit_string(preedit_string, list); -- 2.7.4