svnno****@sourc*****
svnno****@sourc*****
2011年 3月 10日 (木) 22:46:03 JST
Revision: 409 http://sourceforge.jp/projects/swfed/svn/view?view=rev&revision=409 Author: yoya Date: 2011-03-10 22:46:02 +0900 (Thu, 10 Mar 2011) Log Message: ----------- swf_tag_create_input_detail の戻り値チェック Modified Paths: -------------- trunk/src/php_swfed.c trunk/src/swf_object.c trunk/src/swf_tag.c trunk/src/swf_tag.h trunk/src/swf_tag_place.c -------------- next part -------------- Modified: trunk/src/php_swfed.c =================================================================== --- trunk/src/php_swfed.c 2011-03-10 13:15:53 UTC (rev 408) +++ trunk/src/php_swfed.c 2011-03-10 13:46:02 UTC (rev 409) @@ -416,7 +416,9 @@ if ((tag_info == NULL) || (tag_info->detail_handler == NULL)) { RETURN_FALSE; } - swf_tag_create_input_detail(tag, swf); + if (swf_tag_create_input_detail(tag, swf) == NULL) { + RETURN_FALSE; // can't create detail + } switch (tag->tag) { swf_tag_jpeg_detail_t *tag_jpeg; swf_tag_lossless_detail_t *tag_lossless; Modified: trunk/src/swf_object.c =================================================================== --- trunk/src/swf_object.c 2011-03-10 13:15:53 UTC (rev 408) +++ trunk/src/swf_object.c 2011-03-10 13:46:02 UTC (rev 409) @@ -768,10 +768,11 @@ if ((tag->tag != 12) && (tag->tag != 59)) { // DoAction, DoInitAction return NULL; } - if (tag->detail == NULL) { - swf_tag_create_input_detail(tag, swf); + swf_tag_action = (swf_tag_action_detail_t *) swf_tag_create_input_detail(tag, swf); + if (swf_tag_action == NULL) { + fprintf(stderr, "swf_object_get_actiondata: swf_tag_create_input_detail failed"); + return NULL; } - swf_tag_action = (swf_tag_action_detail_t *) tag->detail; *length = swf_tag_action->action_record_len; return swf_tag_action->action_record; } @@ -853,17 +854,19 @@ int tag_no = tag->tag; if (isPlaceTag(tag_no)) { swf_tag_place_detail_t *tag_place; - if (tag->detail == NULL) { - swf_tag_create_input_detail(tag, NULL); + tag_place = swf_tag_create_input_detail(tag, NULL); + if (tag_place == NULL) { + fprintf(stderr, "trans_table_reserve_place_depth_recursive: tag_place swf_tag_create_input_detail failed\n"); + continue; // skip wrong place tag; } - tag_place = tag->detail; trans_table_set(depth_trans_table, tag_place->depth, TRANS_TABLE_RESERVE_ID); } else if (isSpriteTag(tag_no)) { swf_tag_sprite_detail_t *tag_sprite; - if (tag->detail == NULL) { - swf_tag_create_input_detail(tag, NULL); + tag_sprite = swf_tag_create_input_detail(tag, NULL); + if (tag_sprite == NULL) { + fprintf(stderr, "trans_table_reserve_place_depth_recursive: tag_sprite swf_tag_create_input_detail failed\n"); + continue; // skip wrong sprite tag } - tag_sprite = tag->detail; trans_table_reserve_place_depth_recursive(tag_sprite->tag, depth_trans_table); } } @@ -879,18 +882,21 @@ if (isPlaceTag(tag_no)) { swf_tag_place_detail_t *tag_place; int depth; - if (tag->detail == NULL) { - swf_tag_create_input_detail(tag, NULL); + tag_place = swf_tag_create_input_detail(tag, NULL); + if (tag_place == NULL) { + fprintf(stderr, "trans_table_replace_place_depth_recursive: tag_place swf_tag_create_input_detail failed"); + continue; // skip wrong place tag + } - tag_place = tag->detail; depth = tag_place->depth; tag_place = tag->detail; } else if (isSpriteTag(tag_no)) { swf_tag_sprite_detail_t *tag_sprite; - if (tag->detail == NULL) { - swf_tag_create_input_detail(tag, NULL); + tag_sprite = swf_tag_create_input_detail(tag, NULL); + if (tag_sprite == NULL) { + fprintf(stderr, "trans_table_replace_place_depth_recursive: tag_sprite swf_tag_create_input_detail failed"); + continue; // skip wrong sprite tag } - tag_sprite = tag->detail; trans_table_reserve_place_depth_recursive(tag_sprite->tag, depth_trans_table); } } @@ -905,10 +911,10 @@ int tag_no = tag->tag; if (isSpriteTag(tag_no)) { swf_tag_sprite_detail_t *tag_sprite; - if (tag->detail == NULL) { - swf_tag_create_input_detail(tag, NULL); + tag_sprite = swf_tag_create_input_detail(tag, NULL); + if (tag_sprite == NULL) { + fprintf(stderr, "trans_table_replace_refcid_recursive: tag_sprite swf_tag_create_input_detail failed"); } - tag_sprite = tag->detail; trans_table_replace_refcid_recursive(tag_sprite->tag, cid_trans_table); } else if (isPlaceTag(tag_no)) { int refcid = swf_tag_get_refcid(tag); @@ -1069,10 +1075,10 @@ } } else if (isSpriteTag(tag_no)) { swf_tag_sprite_detail_t *s; - if (tag->detail == NULL) { - swf_tag_create_input_detail(tag, swf); + s = swf_tag_create_input_detail(tag, swf); + if (s == NULL) { + fprintf(stderr, "swf_object_replace_movieclip: s swf_tag_create_input_detail failed"); } - s = tag->detail; // 未使用 trans_table_replace_refcid_recursive(s->tag, cid_trans_table); } Modified: trunk/src/swf_tag.c =================================================================== --- trunk/src/swf_tag.c 2011-03-10 13:15:53 UTC (rev 408) +++ trunk/src/swf_tag.c 2011-03-10 13:46:02 UTC (rev 409) @@ -247,12 +247,15 @@ } } -int swf_tag_create_input_detail(swf_tag_t *tag, struct swf_object_ *swf) { +void *swf_tag_create_input_detail(swf_tag_t *tag, struct swf_object_ *swf) { swf_tag_info_t *tag_info = NULL; if (tag == NULL) { fprintf(stderr, "swf_tag_create_input_detail: tag == NULL\n"); - return 1; + return NULL; } + if (tag->detail) { + return tag->detail; + } tag_info = get_swf_tag_info(tag->tag); if (tag_info && tag_info->detail_handler) { int result; @@ -260,20 +263,20 @@ if (detail_handler->create == NULL) { fprintf(stderr, "detail_handler->create == NULL (tag=%d)\n", tag->tag); - return 1; + return NULL; } tag->detail = detail_handler->create(); if (tag->detail == NULL) { fprintf(stderr, "can't create tag detail (tag=%d)\n", tag->tag); - return 1; + return NULL; } result = detail_handler->input(tag, swf); if (result) { fprintf(stderr, "can't input tag detail (result=%d)\n", result); - return 1; + return NULL; } } - return 1; + return tag->detail; } int @@ -292,7 +295,6 @@ return detail_handler->get_cid(tag); } } else { - int cid; switch (tag_no) { case 7: // DefineButton case 10: // DefineFont Modified: trunk/src/swf_tag.h =================================================================== --- trunk/src/swf_tag.h 2011-03-10 13:15:53 UTC (rev 408) +++ trunk/src/swf_tag.h 2011-03-10 13:46:02 UTC (rev 409) @@ -94,7 +94,7 @@ int initial_text_len, struct swf_object_ *swf); -extern int swf_tag_create_input_detail(swf_tag_t *tag, struct swf_object_ *swf); +extern void *swf_tag_create_input_detail(swf_tag_t *tag, struct swf_object_ *swf); extern int swf_tag_apply_shape_matrix_factor(swf_tag_t *tag, int shape_id, double scale_x, double scale_y, Modified: trunk/src/swf_tag_place.c =================================================================== --- trunk/src/swf_tag_place.c 2011-03-10 13:15:53 UTC (rev 408) +++ trunk/src/swf_tag_place.c 2011-03-10 13:46:02 UTC (rev 409) @@ -262,10 +262,10 @@ fprintf(stderr, "swf_tag_place_get_cid_by_instance_name: ! isPlaceTag(%d)\n", tag->tag); return -1; // wrong tag } - if (! tag->detail) { - swf_tag_create_input_detail(tag, swf); + swf_tag_place = (swf_tag_place_detail_t *) swf_tag_create_input_detail(tag, swf); + if (swf_tag_place == NULL) { + fprintf(stderr, "swf_tag_place_get_cid_by_instance_name: swf_tag_place swf_tag_create_input_detail failed\n"); } - swf_tag_place = (swf_tag_place_detail_t *) tag->detail; if (swf_tag_place->flag_has_name == 0) { return -2; // no name }