From: yoya Date: Thu, 17 Mar 2011 07:11:26 +0000 (+0000) Subject: - NULL チェック X-Git-Tag: v0_60~320 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=634f40279a292932023fae9441ec09736b780a0f;p=swfed%2Fswfed.git - NULL チェック - free 前に危ないメンバに NULL 代入 git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/swfed/trunk@434 7c90b180-03d5-4157-b861-58a559ae9d1e --- diff --git a/src/swf_object.c b/src/swf_object.c index 802da30..29a6851 100644 --- a/src/swf_object.c +++ b/src/swf_object.c @@ -43,6 +43,7 @@ swf_object_close(swf_object_t *swf) { next_tag = tag->next; swf_tag_destroy(tag); } + swf->tag = NULL; free(swf); } malloc_debug_end(); /* DEBUG XXX */ @@ -133,10 +134,19 @@ swf_object_input(swf_object_t *swf, unsigned char *data, unsigned char * swf_object_output(swf_object_t *swf, unsigned long *length) { int result; - swf_tag_t *tag; - unsigned char *data; - bitstream_t *bs = bitstream_open(); + swf_tag_t *tag = NULL; + unsigned char *data = NULL; + bitstream_t *bs = NULL; + if (swf == NULL) { + fprintf(stderr, "swf_object_output: swf == NULL\n"); + return NULL; + } + if (length == NULL) { + fprintf(stderr, "swf_object_output: length == NULL\n"); + return NULL; + } *length = 0; + bs = bitstream_open(); result = swf_header_build(bs, &swf->header); if (result) { bitstream_close(bs); @@ -575,11 +585,15 @@ unsigned char * swf_object_get_pngdata(swf_object_t *swf, unsigned long *length, int image_id) { swf_tag_t *tag; unsigned char *data = NULL; - *length = 0; if (swf == NULL) { fprintf(stderr, "swf_object_get_pngdata: swf == NULL\n"); return NULL; } + if (length == NULL) { + fprintf(stderr, "swf_object_get_pngdata: length == NULL\n"); + return NULL; + } + *length = 0; for (tag=swf->tag ; tag ; tag=tag->next) { // DefineBitsLossless(1),2 if ((tag->tag != 20) && (tag->tag != 36)) { @@ -604,6 +618,10 @@ swf_object_replace_pngdata(swf_object_t *swf, int image_id, fprintf(stderr, "swf_object_replace_pngdata: swf == NULL\n"); return 1; } + if (png_data == NULL) { + fprintf(stderr, "swf_object_replace_pngdata: png_data == NULL\n"); + return 1; + } tag = swf_object_search_bitmap_tag(swf, image_id); if (tag == NULL) { fprintf(stderr, "swf_object_replace_pngdata: tag == NULL\n"); @@ -642,6 +660,10 @@ swf_object_replace_gifdata(swf_object_t *swf, int image_id, fprintf(stderr, "swf_object_replace_gifdata: swf == NULL\n"); return 1; } + if (gif_data == NULL) { + fprintf(stderr, "swf_object_replace_gifdata: gif_data == NULL\n"); + return 1; + } tag = swf_object_search_bitmap_tag(swf, image_id); if (tag == NULL) { fprintf(stderr, "swf_object_replace_gifdata: tag == NULL\n"); @@ -676,6 +698,10 @@ swf_object_get_sounddata(swf_object_t *swf, unsigned long *length, int sound_id) fprintf(stderr, "swf_object_get_sounddata: swf == NULL\n"); return NULL; } + if (length == NULL) { + fprintf(stderr, "swf_object_get_sounddata: length == NULL\n"); + return NULL; + } for (tag=swf->tag ; tag ; tag=tag->next) { // DefineSound if (tag->tag != 14) { @@ -699,6 +725,10 @@ swf_object_replace_melodata(swf_object_t *swf, int sound_id, fprintf(stderr, "swf_object_replace_melodata: swf == NULL\n"); return 1; } + if (melo_data == NULL) { + fprintf(stderr, "swf_object_replace_melodata: melo_data == NULL\n"); + return 1; + } for (tag=swf->tag ; tag ; tag=tag->next) { result = swf_tag_replace_melo_data(tag, sound_id, melo_data, melo_data_len); @@ -719,6 +749,10 @@ swf_object_get_editstring(swf_object_t *swf, fprintf(stderr, "swf_object_get_editstring: swf == NULL\n"); return NULL; } + if (variable_name == NULL) { + fprintf(stderr, "swf_object_get_editstring: variable_name == NULL\n"); + return NULL; + } for (tag=swf->tag ; tag ; tag=tag->next) { data = swf_tag_get_edit_string(tag, variable_name, variable_name_len, swf); @@ -759,6 +793,10 @@ swf_object_get_actiondata(swf_object_t *swf, unsigned long *length, int tag_seqn swf_tag_t *tag; swf_tag_action_detail_t *swf_tag_action; int i = 0; + if (swf == NULL) { + fprintf(stderr, "swf_object_get_actiondata: swf == NULL\n"); + return NULL; + } for (tag=swf->tag ; tag ; tag=tag->next) { if (i == tag_seqno) { break;