diff options
author | Jean-Philippe Andre <jp.andre@samsung.com> | 2015-10-01 17:34:20 +0900 |
---|---|---|
committer | Jean-Philippe Andre <jp.andre@samsung.com> | 2015-10-01 18:07:04 +0900 |
commit | 7c8ca6b752b3f584b84aac78d8ee28bf6a6f562a (patch) | |
tree | 751c8a00509c75d26af02b9976fc3d491a3366a1 /src/bin/edje | |
parent | cf2b9ea5caa1570d1f9aa09bf0e3ed381b84ddef (diff) |
edje_cc: Fix TEXT part validation for aliased parts
Not 100% sure of this fix but it "works". This is just compile-time
safety checking code after all, so it won't impact any existing
application.
This fixes commit d4444bf7a0e368097bec555. Tested with empc.
Thanks @zmike for the report and test case.
Diffstat (limited to 'src/bin/edje')
-rw-r--r-- | src/bin/edje/edje_cc_out.c | 80 |
1 files changed, 67 insertions, 13 deletions
diff --git a/src/bin/edje/edje_cc_out.c b/src/bin/edje/edje_cc_out.c index c0264e69b8..5c79ee8298 100644 --- a/src/bin/edje/edje_cc_out.c +++ b/src/bin/edje/edje_cc_out.c | |||
@@ -382,32 +382,86 @@ check_image_part_desc(Edje_Part_Collection *pc, Edje_Part *ep, | |||
382 | } | 382 | } |
383 | } | 383 | } |
384 | 384 | ||
385 | static Edje_Part_Collection * | ||
386 | _source_group_find(const char *source) | ||
387 | { | ||
388 | Edje_Part_Collection *pc2; | ||
389 | Eina_List *l; | ||
390 | if (!source) return NULL; | ||
391 | EINA_LIST_FOREACH(edje_collections, l, pc2) | ||
392 | { | ||
393 | if (!strcmp(pc2->part, source)) | ||
394 | return pc2; | ||
395 | } | ||
396 | return NULL; | ||
397 | } | ||
398 | |||
399 | static Edje_Part * | ||
400 | _aliased_text_part_find(Edje_Part_Collection *pc, | ||
401 | int id_source, const char *id_source_part) | ||
402 | { | ||
403 | Edje_Part_Collection *group; | ||
404 | unsigned int i; | ||
405 | |||
406 | if (!pc->parts[id_source]->source) | ||
407 | return NULL; | ||
408 | |||
409 | group = _source_group_find(pc->parts[id_source]->source); | ||
410 | if (!group) return NULL; | ||
411 | |||
412 | for (i = 0; i < group->parts_count; i++) | ||
413 | { | ||
414 | if (!strcmp(group->parts[i]->name, id_source_part)) | ||
415 | return group->parts[i]; | ||
416 | } | ||
417 | return NULL; | ||
418 | } | ||
419 | |||
385 | static void | 420 | static void |
386 | check_text_part_desc(Edje_Part_Collection *pc, Edje_Part *ep, | 421 | check_text_part_desc(Edje_Part_Collection *pc, Edje_Part *ep, |
387 | Edje_Part_Description_Text *epd, Eet_File *ef) | 422 | Edje_Part_Description_Text *epd, Eet_File *ef) |
388 | { | 423 | { |
424 | Edje_Part *ep2; | ||
425 | |||
389 | if (epd->text.id_source != -1) | 426 | if (epd->text.id_source != -1) |
390 | { | 427 | { |
391 | if ((pc->parts[epd->text.id_source]->type != EDJE_PART_TYPE_TEXT) && | 428 | if ((pc->parts[epd->text.id_source]->type == EDJE_PART_TYPE_TEXT) || |
392 | (pc->parts[epd->text.id_source]->type != EDJE_PART_TYPE_TEXTBLOCK)) | 429 | (pc->parts[epd->text.id_source]->type == EDJE_PART_TYPE_TEXTBLOCK)) |
430 | return; | ||
431 | |||
432 | if (epd->text.id_source_part) | ||
393 | { | 433 | { |
394 | error_and_abort(ef, "Collection \"%s\" Part \"%s\" Description \"%s\" [%.3f]: " | 434 | ep2 = _aliased_text_part_find(pc, epd->text.id_source, epd->text.id_source_part); |
395 | "text.source point to a non TEXT part \"%s\"!", | 435 | if (ep2 && ((ep2->type == EDJE_PART_TYPE_TEXT) || |
396 | pc->part, ep->name,epd->common.state.name, | 436 | (ep2->type == EDJE_PART_TYPE_TEXTBLOCK))) |
397 | epd->common.state.value, pc->parts[epd->text.id_source]->name); | 437 | return; |
398 | } | 438 | } |
439 | |||
440 | error_and_abort(ef, "Collection \"%s\" Part \"%s\" Description \"%s\" [%.3f]: " | ||
441 | "text.source point to a non TEXT part \"%s\"!", | ||
442 | pc->part, ep->name, epd->common.state.name, | ||
443 | epd->common.state.value, pc->parts[epd->text.id_source]->name); | ||
399 | } | 444 | } |
400 | 445 | ||
401 | if (epd->text.id_text_source != -1) | 446 | if (epd->text.id_text_source != -1) |
402 | { | 447 | { |
403 | if ((pc->parts[epd->text.id_text_source]->type != EDJE_PART_TYPE_TEXT) && | 448 | |
404 | (pc->parts[epd->text.id_text_source]->type != EDJE_PART_TYPE_TEXTBLOCK)) | 449 | if ((pc->parts[epd->text.id_text_source]->type == EDJE_PART_TYPE_TEXT) || |
450 | (pc->parts[epd->text.id_text_source]->type == EDJE_PART_TYPE_TEXTBLOCK)) | ||
451 | return; | ||
452 | |||
453 | if (epd->text.id_text_source_part) | ||
405 | { | 454 | { |
406 | error_and_abort(ef, "Collection \"%s\" Part \"%s\" Description \"%s\" [%.3f]: " | 455 | ep2 = _aliased_text_part_find(pc, epd->text.id_text_source, epd->text.id_text_source_part); |
407 | "text.text_source point to a non TEXT part \"%s\"!", | 456 | if (ep2 && ((ep2->type == EDJE_PART_TYPE_TEXT) || |
408 | pc->part, ep->name,epd->common.state.name, | 457 | (ep2->type == EDJE_PART_TYPE_TEXTBLOCK))) |
409 | epd->common.state.value, pc->parts[epd->text.id_text_source]->name); | 458 | return; |
410 | } | 459 | } |
460 | |||
461 | error_and_abort(ef, "Collection \"%s\" Part \"%s\" Description \"%s\" [%.3f]: " | ||
462 | "text.text_source point to a non TEXT part \"%s\"!", | ||
463 | pc->part, ep->name,epd->common.state.name, | ||
464 | epd->common.state.value, pc->parts[epd->text.id_text_source]->name); | ||
411 | } | 465 | } |
412 | } | 466 | } |
413 | 467 | ||