summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2014-01-24 09:44:40 +0900
committerCedric BAIL <cedric.bail@samsung.com>2014-01-24 09:47:08 +0900
commit345c1ad26de0cab75e1127b74103248c1f647e85 (patch)
tree563ed36420c7af3ce68fd654526fdd79d9e047c7 /src
parent5593964ead053d980db60ac42acf194040b85452 (diff)
evas: textgrid - fix crash in terminology with rare characters.
So I have a weird crash in terminology. Reproduction path: eet -x /path/to/elm/theme/default.edj edje/images/537 Scroll back in the terminal buffer, to show the entire file: CRASH. Reviewers: cedric, tasn CC: cedric, raster Differential Revision: https://phab.enlightenment.org/D468 Signed-off-by: Cedric BAIL <cedric.bail@samsung.com>
Diffstat (limited to 'src')
-rw-r--r--src/lib/evas/canvas/evas_object_textgrid.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/lib/evas/canvas/evas_object_textgrid.c b/src/lib/evas/canvas/evas_object_textgrid.c
index 2e0e592d7c..a54af9ad72 100644
--- a/src/lib/evas/canvas/evas_object_textgrid.c
+++ b/src/lib/evas/canvas/evas_object_textgrid.c
@@ -297,14 +297,18 @@ evas_object_textgrid_textprop_ref(Evas_Object *eo_obj, Evas_Object_Textgrid *o,
297 } 297 }
298 offset--; 298 offset--;
299 } 299 }
300 if (o->master[offset].next[(codepoint & mask) >> shift] == 0) 300 if ((o->master[offset].next[(codepoint & mask) >> shift] == 0)
301 || ((o->master[offset].next[(codepoint & mask) >> shift] & 0xFFFFFF) >= o->glyphs_length))
301 { 302 {
302 Evas_Textgrid_Hash_Glyphs *tmp; 303 Evas_Textgrid_Hash_Glyphs *tmp;
303 unsigned char *tmp_used; 304 unsigned char *tmp_used;
304 int count; 305 int count, i;
305 306
306 /* FIXME: find empty entry */ 307 /* FIXME: find empty entry */
307 count = o->glyphs_length + 1; 308 if (o->master[offset].next[(codepoint & mask) >> shift] == 0)
309 count = o->glyphs_length + 1;
310 else
311 count = (o->master[offset].next[(codepoint & mask) >> shift] & 0xFFFFFF) + 1;
308 tmp = realloc(o->glyphs, count * sizeof (Evas_Textgrid_Hash_Glyphs)); 312 tmp = realloc(o->glyphs, count * sizeof (Evas_Textgrid_Hash_Glyphs));
309 if (!tmp) return 0xFFFFFFFF; 313 if (!tmp) return 0xFFFFFFFF;
310 o->glyphs = tmp; 314 o->glyphs = tmp;
@@ -312,10 +316,11 @@ evas_object_textgrid_textprop_ref(Evas_Object *eo_obj, Evas_Object_Textgrid *o,
312 if (!tmp_used) return 0xFFFFFFFF; 316 if (!tmp_used) return 0xFFFFFFFF;
313 o->glyphs_used = tmp_used; 317 o->glyphs_used = tmp_used;
314 318
319 // FIXME: What should we write when allocating more than one new entry?
315 o->master[offset].next[(codepoint & mask) >> shift] = o->glyphs_length + 0xFF000000; 320 o->master[offset].next[(codepoint & mask) >> shift] = o->glyphs_length + 0xFF000000;
316 321
317 memset(o->glyphs + o->glyphs_length, 0, sizeof (Evas_Textgrid_Hash_Glyphs)); 322 memset(o->glyphs + o->glyphs_length, 0, (count - o->glyphs_length) * sizeof (Evas_Textgrid_Hash_Glyphs));
318 o->glyphs_used[o->glyphs_length] = 0; 323 memset(o->glyphs_used, 0, (count - o->glyphs_length) * sizeof(o->glyphs_used[0]));
319 o->glyphs_length = count; 324 o->glyphs_length = count;
320 } 325 }
321 326