colorclass: allocate memory to fit the original size of data type 91/61891/1
authorJee-Yong Um <jc9.um@samsung.com>
Fri, 11 Mar 2016 05:18:19 +0000 (14:18 +0900)
committerJee-Yong Um <jc9.um@samsung.com>
Fri, 11 Mar 2016 05:25:03 +0000 (14:25 +0900)
backported from upstream to solve memory safety issue

    Summary:
    The size of Colorclass is 20 bytes, but that of Elm_Color_Overlay 16 bytes.
    Currently, there is no code to access last 4 bytes, but it can cause
    seg fault by another patch.

    Reviewers: cedric, zmike

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

Change-Id: I2b51a8f352a70968e7a97a128eea24fdab04c40e
Signed-By-Off: Jee-Yong Um <jc9.um@samsung.com>

src/lib/elm_color_class.c

index 6d36ec8..39b90da 100644 (file)
@@ -218,7 +218,7 @@ _colorclass_activate(void *data, Eo *obj EINA_UNUSED,
      }
    else
      {
-        cc->current = malloc(sizeof(Elm_Color_Overlay));
+        cc->current = calloc(1, sizeof(Colorclass)); //actually Elm_Color_Overlay
         memcpy(cc->current, ecc, sizeof(Elm_Color_Overlay));
         cc->current->name = eina_stringshare_ref(ecc->name);
      }