svnno****@sourc*****
svnno****@sourc*****
2009年 2月 11日 (水) 15:12:28 JST
Revision: 111 http://svn.sourceforge.jp/view?root=swfed&view=rev&rev=111 Author: yoya Date: 2009-02-11 15:12:28 +0900 (Wed, 11 Feb 2009) Log Message: ----------- 変数の初期化漏れを修正 (compress 格納先buff のデータ長指定) Modified Paths: -------------- trunk/src/swf_object.c trunk/src/swf_tag_jpeg.c -------------- next part -------------- Modified: trunk/src/swf_object.c =================================================================== --- trunk/src/swf_object.c 2009-02-11 05:47:01 UTC (rev 110) +++ trunk/src/swf_object.c 2009-02-11 06:12:28 UTC (rev 111) @@ -130,13 +130,14 @@ ; // OK } else if (memcmp(swf->header.magic, "CWS", SWF_MAGIC_SIZE) == 0) { int result; - unsigned long compsize; + unsigned long compsize, old_size; unsigned char *new_buff, *old_buff_ref; bitstream_setpos(bs, SWF_HEADER_SIZE, 0); old_buff_ref = bitstream_buffer(bs, SWF_HEADER_SIZE); - new_buff = malloc(swf->header.file_length - SWF_HEADER_SIZE); - result = compress(new_buff, &compsize, old_buff_ref, - bs->data_len - SWF_HEADER_SIZE); + old_size = bs->data_len - SWF_HEADER_SIZE; + compsize = old_size; + new_buff = malloc(compsize); + result = compress(new_buff, &compsize, old_buff_ref, old_size); if (result != Z_OK) { if (result == Z_MEM_ERROR) { fprintf(stderr, "swf_object_output: compress Z_MEM_ERROR: can't malloc\n"); Modified: trunk/src/swf_tag_jpeg.c =================================================================== --- trunk/src/swf_tag_jpeg.c 2009-02-11 05:47:01 UTC (rev 110) +++ trunk/src/swf_tag_jpeg.c 2009-02-11 06:12:28 UTC (rev 111) @@ -178,7 +178,7 @@ bitstream_t *bs; unsigned char *data, *new_buff; unsigned long offset_to_alpha; - unsigned long compsize; + unsigned long compsize, old_size; (void) swf; *length = 0; bs = bitstream_open(); @@ -186,8 +186,10 @@ bitstream_putbytesLE(bs, swf_tag_jpeg->jpeg_data_len, 4); bitstream_putstring(bs, swf_tag_jpeg->jpeg_data, swf_tag_jpeg->jpeg_data_len); offset_to_alpha = swf_tag_jpeg->jpeg_data_len; - new_buff = malloc(swf_tag_jpeg->alpha_data_len); // too enough memory - compress(new_buff, &compsize, swf_tag_jpeg->alpha_data, swf_tag_jpeg->alpha_data_len); + 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); bitstream_putstring(bs, new_buff, compsize); free(new_buff); data = bitstream_steal(bs, length);