svnno****@sourc*****
svnno****@sourc*****
2009年 2月 11日 (水) 15:14:34 JST
Revision: 112 http://svn.sourceforge.jp/view?root=swfed&view=rev&rev=112 Author: yoya Date: 2009-02-11 15:14:34 +0900 (Wed, 11 Feb 2009) Log Message: ----------- compress のエラーをチェックする処理を追加 Modified Paths: -------------- trunk/src/swf_tag_jpeg.c trunk/src/swf_tag_lossless.c -------------- next part -------------- Modified: trunk/src/swf_tag_jpeg.c =================================================================== --- trunk/src/swf_tag_jpeg.c 2009-02-11 06:12:28 UTC (rev 111) +++ trunk/src/swf_tag_jpeg.c 2009-02-11 06:14:34 UTC (rev 112) @@ -179,6 +179,7 @@ unsigned char *data, *new_buff; unsigned long offset_to_alpha; unsigned long compsize, old_size; + int result; (void) swf; *length = 0; bs = bitstream_open(); @@ -189,7 +190,19 @@ old_size = swf_tag_jpeg->alpha_data_len; compsize = old_size; new_buff = malloc(compsize); // too enough memory - compress(new_buff, &compsize, swf_tag_jpeg->alpha_data, old_size); + result = compress(new_buff, &compsize, swf_tag_jpeg->alpha_data, old_size); + if (result != Z_OK) { + if (result == Z_MEM_ERROR) { + fprintf(stderr, "swf_tag_jpeg_output_detail: compress Z_MEM_ERROR: can't malloc\n"); + } else if (result == Z_BUF_ERROR) { + fprintf(stderr, "swf_tag_jpeg_output_detail: compress Z_BUF_ERROR: not enough buff size\n"); + } else { + fprintf(stderr, "swf_tag_jpeg_output_detail: compress failed by unknown reason\n"); + } + free(new_buff); + bitstream_close(bs); + return NULL; // FAILURE + } bitstream_putstring(bs, new_buff, compsize); free(new_buff); data = bitstream_steal(bs, length); Modified: trunk/src/swf_tag_lossless.c =================================================================== --- trunk/src/swf_tag_lossless.c 2009-02-11 06:12:28 UTC (rev 111) +++ trunk/src/swf_tag_lossless.c 2009-02-11 06:14:34 UTC (rev 112) @@ -206,6 +206,7 @@ unsigned long i; unsigned char *tmp_buff, *old_buff_ref; unsigned long compsize, old_size; + int result; (void) swf; *length = 0; bs = bitstream_open(); @@ -235,7 +236,20 @@ old_size = bitstream_length(bs2); compsize = old_size; tmp_buff = malloc(compsize); - compress(tmp_buff, &compsize, old_buff_ref, old_size); + result = compress(tmp_buff, &compsize, old_buff_ref, old_size); + if (result != Z_OK) { + if (result == Z_MEM_ERROR) { + fprintf(stderr, "swf_tag_lossless_output_detail: compress Z_MEM_ERROR: can't malloc\n"); + } else if (result == Z_BUF_ERROR) { + fprintf(stderr, "swf_tag_lossless_output_detail: compress Z_BUF_ERROR: not enough buff size\n"); + } else { + fprintf(stderr, "swf_tag_lossless_output_detail: compress failed by unknown reason\n"); + } + bitstream_close(bs2); + bitstream_close(bs); + free(tmp_buff); + return NULL; // FAILURE + } bitstream_putstring(bs, tmp_buff, compsize); bitstream_close(bs2); free(tmp_buff); @@ -259,7 +273,20 @@ old_size = bitstream_length(bs2); compsize = old_size; tmp_buff = malloc(compsize); - compress(tmp_buff, &compsize, old_buff_ref, old_size); + result = compress(tmp_buff, &compsize, old_buff_ref, old_size); + if (result != Z_OK) { + if (result == Z_MEM_ERROR) { + fprintf(stderr, "swf_tag_lossless_output_detail: compress Z_MEM_ERROR: can't malloc\n"); + } else if (result == Z_BUF_ERROR) { + fprintf(stderr, "swf_tag_lossless_output_detail: compress Z_BUF_ERROR: not enough buff size\n"); + } else { + fprintf(stderr, "swf_tag_lossless_output_detail: compress failed by unknown reason\n"); + } + bitstream_close(bs2); + bitstream_close(bs); + free(tmp_buff); + return NULL; // FAILURE + } bitstream_putstring(bs, tmp_buff, compsize); bitstream_close(bs2); free(tmp_buff);