From 7707d7b93fb22819ec8913dc0c12030a5dc84680 Mon Sep 17 00:00:00 2001 From: yoya Date: Wed, 11 Feb 2009 06:12:28 +0000 Subject: [PATCH] =?utf8?q?=E5=A4=89=E6=95=B0=E3=81=AE=E5=88=9D=E6=9C=9F?= =?utf8?q?=E5=8C=96=E6=BC=8F=E3=82=8C=E3=82=92=E4=BF=AE=E6=AD=A3=20(compre?= =?utf8?q?ss=20=E6=A0=BC=E7=B4=8D=E5=85=88buff=20=E3=81=AE=E3=83=87?= =?utf8?q?=E3=83=BC=E3=82=BF=E9=95=B7=E6=8C=87=E5=AE=9A)?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/swfed/trunk@111 7c90b180-03d5-4157-b861-58a559ae9d1e --- src/swf_object.c | 9 +++++---- src/swf_tag_jpeg.c | 8 +++++--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/swf_object.c b/src/swf_object.c index cf0c4ee..8b2ad38 100644 --- a/src/swf_object.c +++ b/src/swf_object.c @@ -130,13 +130,14 @@ swf_object_output(swf_object_t *swf, unsigned long *length) { ; // 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"); diff --git a/src/swf_tag_jpeg.c b/src/swf_tag_jpeg.c index cf614fc..8c22f78 100644 --- a/src/swf_tag_jpeg.c +++ b/src/swf_tag_jpeg.c @@ -178,7 +178,7 @@ swf_tag_jpeg3_output_detail(swf_tag_t *tag, unsigned long *length, 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 @@ swf_tag_jpeg3_output_detail(swf_tag_t *tag, unsigned long *length, 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); -- 2.11.0