textblock: Fix crash with filters
authorJean-Philippe André <jpeg@videolan.org>
Wed, 9 Jan 2019 17:46:38 +0000 (12:46 -0500)
committerJiyoun Park <jy0703.park@samsung.com>
Wed, 16 Jan 2019 02:13:20 +0000 (11:13 +0900)
Summary:
A crash could happen on a bad call to free() context_dup() returns a
newly malloc'ed context if passed NULL (this seems dubious to me, why
not calloc?).

@fix

Test Plan:
  Add an empty efl.ui.text object
  Set markup text as "<gfx_filter='code'>Hello</>"

Reviewers: cedric, segfaultxavi, Jaehyun, herdsman, zmike

Reviewed By: zmike

Subscribers: zmike, cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D7368

src/lib/evas/canvas/evas_object_textblock.c

index 9011096..6c38268 100644 (file)
@@ -2897,7 +2897,8 @@ _format_dup(Evas_Object *eo_obj, const Evas_Object_Textblock_Format *fmt)
         fmt2->gfx_filter = malloc(sizeof(*fmt2->gfx_filter));
         memcpy(fmt2->gfx_filter, fmt->gfx_filter, sizeof(*fmt->gfx_filter));
         fmt2->gfx_filter->name = eina_stringshare_ref(fmt->gfx_filter->name);
-        fmt2->gfx_filter->dc = ENFN->context_dup(ENC, fmt->gfx_filter->dc);
+        if (fmt->gfx_filter->dc)
+          fmt2->gfx_filter->dc = ENFN->context_dup(ENC, fmt->gfx_filter->dc);
      }
 
    return fmt2;