summaryrefslogtreecommitdiff
path: root/src/lib/evas/common/evas_font_main.c
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2013-06-04 19:49:30 +0900
committerCedric Bail <cedric.bail@samsung.com>2013-06-04 20:21:16 +0900
commit5836f503e1559f34af0a67143e6fbb24a9bd8f10 (patch)
treef92988e8bdd379dade173c096c6d1259371ea664 /src/lib/evas/common/evas_font_main.c
parente973be52f90df7c620ad5c0010570cd01aa92739 (diff)
evas/cserve2: fix crash in cserve2's font loading mechanism.
Signed-off-by: Cedric Bail <cedric.bail@samsung.com>
Diffstat (limited to '')
-rw-r--r--src/lib/evas/common/evas_font_main.c37
1 files changed, 27 insertions, 10 deletions
diff --git a/src/lib/evas/common/evas_font_main.c b/src/lib/evas/common/evas_font_main.c
index 860574a1c0..1de4a56ee4 100644
--- a/src/lib/evas/common/evas_font_main.c
+++ b/src/lib/evas/common/evas_font_main.c
@@ -344,6 +344,18 @@ _fash_int_add(Fash_Int *fash, int item, RGBA_Font_Int *fint, int idx)
344} 344}
345 345
346static void 346static void
347_glyph_free(RGBA_Font_Glyph *fg)
348{
349 if ((!fg) || (fg == (void *)(-1))) return;
350
351 FT_Done_Glyph(fg->glyph);
352 /* extension calls */
353 if (fg->ext_dat_free) fg->ext_dat_free(fg->ext_dat);
354 if (fg->glyph_out_free) fg->glyph_out_free(fg->glyph_out);
355 free(fg);
356}
357
358static void
347_fash_glyph_free(Fash_Glyph_Map *fmap) 359_fash_glyph_free(Fash_Glyph_Map *fmap)
348{ 360{
349 int i; 361 int i;
@@ -353,11 +365,7 @@ _fash_glyph_free(Fash_Glyph_Map *fmap)
353 RGBA_Font_Glyph *fg = fmap->item[i]; 365 RGBA_Font_Glyph *fg = fmap->item[i];
354 if ((fg) && (fg != (void *)(-1))) 366 if ((fg) && (fg != (void *)(-1)))
355 { 367 {
356 FT_Done_Glyph(fg->glyph); 368 _glyph_free(fg);
357 /* extension calls */
358 if (fg->ext_dat_free) fg->ext_dat_free(fg->ext_dat);
359 if (fg->glyph_out_free) fg->glyph_out_free(fg->glyph_out);
360 free(fg);
361 fmap->item[i] = NULL; 369 fmap->item[i] = NULL;
362 } 370 }
363 } 371 }
@@ -443,10 +451,20 @@ evas_common_font_int_cache_glyph_get(RGBA_Font_Int *fi, FT_UInt idx)
443 { 451 {
444#ifdef EVAS_CSERVE2 452#ifdef EVAS_CSERVE2
445 if (fi->cs2_handler) 453 if (fi->cs2_handler)
446 evas_cserve2_font_glyph_used(fi->cs2_handler, idx, 454 {
447 fi->hinting); 455 if (evas_cserve2_font_glyph_used(fi->cs2_handler, idx,
448#endif 456 fi->hinting))
457 return fg;
458 else
459 {
460 _glyph_free(fg);
461 _fash_gl_add(fi->fash, idx, NULL);
462 }
463 }
464 else return fg;
465#else
449 return fg; 466 return fg;
467#endif
450 } 468 }
451 } 469 }
452// fg = eina_hash_find(fi->glyphs, &hindex); 470// fg = eina_hash_find(fi->glyphs, &hindex);
@@ -472,9 +490,8 @@ evas_common_font_int_cache_glyph_get(RGBA_Font_Int *fi, FT_UInt idx)
472 if (fi->runtime_rend & FONT_REND_WEIGHT) 490 if (fi->runtime_rend & FONT_REND_WEIGHT)
473 FT_GlyphSlot_Embolden(fi->src->ft.face->glyph); 491 FT_GlyphSlot_Embolden(fi->src->ft.face->glyph);
474 492
475 fg = malloc(sizeof(struct _RGBA_Font_Glyph)); 493 fg = calloc(1, sizeof(RGBA_Font_Glyph));
476 if (!fg) return NULL; 494 if (!fg) return NULL;
477 memset(fg, 0, (sizeof(struct _RGBA_Font_Glyph)));
478 495
479 FTLOCK(); 496 FTLOCK();
480 error = FT_Get_Glyph(fi->src->ft.face->glyph, &(fg->glyph)); 497 error = FT_Get_Glyph(fi->src->ft.face->glyph, &(fg->glyph));