evas/scale_sample: call alloca for the scanline buffer after clamping width
authorMike Blumenkrantz <zmike@samsung.com>
Mon, 13 May 2019 15:44:27 +0000 (11:44 -0400)
committerJunsuChoi <jsuya.choi@samsung.com>
Thu, 30 May 2019 08:17:50 +0000 (17:17 +0900)
Summary:
this is already a risky call for larger scanlines, so use the clamped value
to further reduce the chance of blowing out the stack

Depends on D8839

Reviewers: cedric, segfaultxavi

Reviewed By: segfaultxavi

Subscribers: segfaultxavi, #reviewers, #committers

Tags: #efl_rendering

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

src/lib/evas/common/evas_scale_sample.c

index 6fc54de..d043ba3 100644 (file)
@@ -140,9 +140,6 @@ _evas_common_scale_rgba_sample_scale_mask(int y,
    DATA32 *buf, *dst_ptr;
    int x;
 
-   /* a scanline buffer */
-   buf = alloca(dst_clip_w * sizeof(DATA32));
-
    /* clamp/map to mask geometry */
    if (EINA_UNLIKELY(dst_clip_x < mask_x))
      dst_clip_x = mask_x;
@@ -153,6 +150,9 @@ _evas_common_scale_rgba_sample_scale_mask(int y,
    if (EINA_UNLIKELY(dst_clip_y + dst_clip_h > mask_y + (int)mask_ie->cache_entry.h))
      dst_clip_h = mask_y + mask_ie->cache_entry.h - dst_clip_y;
 
+   /* a scanline buffer */
+   buf = alloca(dst_clip_w * sizeof(DATA32));
+
    dptr = dptr + dst_w * y;
    for (; y < dst_clip_h; y++)
      {