Add code to check the return value of calloc 59/139259/1
authorJihoon Kim <jihoon48.kim@samsung.com>
Tue, 18 Jul 2017 06:24:22 +0000 (15:24 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Tue, 18 Jul 2017 06:24:24 +0000 (15:24 +0900)
Pointer 'preedit_attr' returned from function 'calloc' at ise.cpp:431 may be null,
and it is dereferenced at ise.cpp:432.

Change-Id: Ic1f60aee84f567ba8ac22ef00ebcf2de6c879fc6
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
src/ise.cpp

index dcc978d..55ab9a7 100644 (file)
@@ -429,11 +429,13 @@ ise_update_preedit_string(const sclchar *str, const sclboolean underline)
         while (*s) len += (*s++ & 0xc0) != 0x80;
 
         preedit_attr = (ime_preedit_attribute *)calloc(1, sizeof(ime_preedit_attribute));
-        preedit_attr->start = 0;
-        preedit_attr->length = len;
-        preedit_attr->type = IME_ATTR_FONTSTYLE;
-        preedit_attr->value = IME_ATTR_FONTSTYLE_UNDERLINE;
-        attr_list = eina_list_append(attr_list, (void *)preedit_attr);
+        if (preedit_attr) {
+            preedit_attr->start = 0;
+            preedit_attr->length = len;
+            preedit_attr->type = IME_ATTR_FONTSTYLE;
+            preedit_attr->value = IME_ATTR_FONTSTYLE_UNDERLINE;
+            attr_list = eina_list_append(attr_list, (void *)preedit_attr);
+        }
 
         ime_update_preedit_string(str, attr_list);
     } else {