evas filters: Fix a rare crash in text render (SW)
authorJean-Philippe Andre <jp.andre@samsung.com>
Mon, 10 Apr 2017 07:56:14 +0000 (16:56 +0900)
committerJean-Philippe Andre <jp.andre@samsung.com>
Mon, 10 Apr 2017 07:56:14 +0000 (16:56 +0900)
There are reports of crashes when y < 0. This case seems
abnormal in case of filters, as I don't know how to reproduce it,
but it's happened.

Thanks Youngbok Shin for the report.

@fix

src/lib/evas/common/evas_font_compress.c

index 7788ba5..e923e17 100644 (file)
@@ -508,11 +508,24 @@ evas_common_font_glyph_draw(RGBA_Font_Glyph *fg,
         // FIXME: Font draw not optimized for Alpha targets! SLOW!
         // This is not pretty :)
 
-        DATA8 *dst8 = dst_image->image.data8 + x + (y * dst_pitch);
         Alpha_Gfx_Func func;
-        DATA8 *src8;
+        DATA8 *src8, *dst8;
         int row;
 
+        if (EINA_UNLIKELY(x < 0))
+          {
+             x1 += (-x);
+             x = 0;
+             if ((x2 - x1) <= 0) return;
+          }
+        if (EINA_UNLIKELY(y < 0))
+          {
+             y1 += (-y);
+             y = 0;
+             if ((y2 - y1) <= 0) return;
+          }
+
+        dst8 = dst_image->image.data8 + x + (y * dst_pitch);
         func = efl_draw_alpha_func_get(dc->render_op, EINA_FALSE);
         src8 = evas_common_font_glyph_uncompress(fg, NULL, NULL);
         if (!src8) return;