edje: Fix issue of null pointer dereference
authorChris Michael <cp.michael@samsung.com>
Mon, 11 Jul 2016 15:19:01 +0000 (11:19 -0400)
committerChris Michael <cp.michael@samsung.com>
Mon, 11 Jul 2016 15:20:23 +0000 (11:20 -0400)
Coverity reports that 'text' here is a null pointer dereference so
check for valid 'text' variable before trying to use it.

Fixes Coverity CID1267490

@fix

Signed-off-by: Chris Michael <cp.michael@samsung.com>
src/lib/edje/edje_load.c

index 85dc114..c370a72 100644 (file)
@@ -1041,21 +1041,31 @@ _edje_object_file_set_internal(Evas_Object *obj, const Eina_File *file, const ch
                             Edje_Part_Description_Text *text;
 
                             text = (Edje_Part_Description_Text *)rp->param1.description;
-
-                            if (ed->file->feature_ver < 1)
+                            if (text)
                               {
-                                 text->text.id_source = -1;
-                                 text->text.id_text_source = -1;
-                              }
+                                 if (ed->file->feature_ver < 1)
+                                   {
+                                      text->text.id_source = -1;
+                                      text->text.id_text_source = -1;
+                                   }
 
-                            if ((rp->type == EDJE_RP_TYPE_TEXT) &&
-                                (rp->typedata.text))
-                              {
-                                 if (text->text.id_source >= 0)
-                                   rp->typedata.text->source = ed->table_parts[text->text.id_source % ed->table_parts_size];
-                                 if (text->text.id_text_source >= 0)
-                                   rp->typedata.text->text_source = ed->table_parts[text->text.id_text_source % ed->table_parts_size];
+                                 if ((rp->type == EDJE_RP_TYPE_TEXT) &&
+                                     (rp->typedata.text))
+                                   {
+                                      if (text->text.id_source >= 0)
+                                        {
+                                           rp->typedata.text->source =
+                                             ed->table_parts[text->text.id_source % ed->table_parts_size];
+                                        }
+
+                                      if (text->text.id_text_source >= 0)
+                                        {
+                                           rp->typedata.text->text_source =
+                                             ed->table_parts[text->text.id_text_source % ed->table_parts_size];
+                                        }
+                                   }
                               }
+
                             if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
                               {
                                  _edje_entry_real_part_init(ed, rp);