[Swfed-svn] swfed-svn [53] - 全て : destroy_detail の見直し

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2008年 10月 2日 (木) 18:27:13 JST


Revision: 53
          http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=swfed&view=rev&rev=53
Author:   yoya
Date:     2008-10-02 18:27:13 +0900 (Thu, 02 Oct 2008)

Log Message:
-----------
- 全て: destroy_detail の見直し
- swf_tag_jpeg.c: 変数名の見直し (old_buff -> old_buff_ref)

Modified Paths:
--------------
    src/swf_tag_action.c
    src/swf_tag_edit.c
    src/swf_tag_jpeg.c
    src/swf_tag_lossless.c
    src/swf_tag_sound.c


-------------- next part --------------
Modified: src/swf_tag_action.c
===================================================================
--- src/swf_tag_action.c	2008-10-02 08:38:46 UTC (rev 52)
+++ src/swf_tag_action.c	2008-10-02 09:27:13 UTC (rev 53)
@@ -108,9 +108,10 @@
 void
 swf_tag_action_destroy_detail(void *detail) {
     swf_tag_action_detail_t *swf_tag_action = (swf_tag_action_detail_t *) detail;
-    if (swf_tag_action->action_record) {
+    if (swf_tag_action) {
         free(swf_tag_action->action_record);
+        swf_tag_action->action_record = NULL;
+        free(swf_tag_action);
     }
-    free(swf_tag_action);
     return ;
 }

Modified: src/swf_tag_edit.c
===================================================================
--- src/swf_tag_edit.c	2008-10-02 08:38:46 UTC (rev 52)
+++ src/swf_tag_edit.c	2008-10-02 09:27:13 UTC (rev 53)
@@ -228,9 +228,13 @@
 void
 swf_tag_edit_destroy_detail(void *detail) {
     swf_tag_edit_detail_t *swf_tag_edit = (swf_tag_edit_detail_t *) detail;
-    free(swf_tag_edit->edit_variable_name);
-    free(swf_tag_edit->edit_initial_text);
-    free(swf_tag_edit);
+    if (swf_tag_edit) {
+        free(swf_tag_edit->edit_variable_name);
+        free(swf_tag_edit->edit_initial_text);
+        swf_tag_edit->edit_variable_name = NULL;
+        swf_tag_edit->edit_initial_text = NULL;
+        free(swf_tag_edit);
+    }
     return ;
 }
 

Modified: src/swf_tag_jpeg.c
===================================================================
--- src/swf_tag_jpeg.c	2008-10-02 08:38:46 UTC (rev 52)
+++ src/swf_tag_jpeg.c	2008-10-02 09:27:13 UTC (rev 53)
@@ -68,7 +68,7 @@
     unsigned long offset_to_alpha;
     bitstream_t *bs;
     unsigned long  offset, alpha_data_len;
-    unsigned char *old_buff, *new_buff;
+    unsigned char *old_buff_ref, *new_buff;
     unsigned long origsize;
     int result;
     (void) tag;
@@ -96,8 +96,8 @@
     alpha_data_len = length - offset;
     origsize = 256 * alpha_data_len;
     new_buff = malloc(origsize);
-    old_buff = bitstream_buffer(bs, offset);
-    result = uncompress(new_buff, &origsize, old_buff, alpha_data_len);
+    old_buff_ref = bitstream_buffer(bs, offset);
+    result = uncompress(new_buff, &origsize, old_buff_ref, alpha_data_len);
     if (result == Z_OK) {
         swf_tag_jpeg->alpha_data = realloc(new_buff, origsize);
         swf_tag_jpeg->alpha_data = new_buff;
@@ -219,16 +219,13 @@
 void
 swf_tag_jpeg_destroy_detail(void *detail) {
     swf_tag_jpeg_detail_t *swf_tag_jpeg = (swf_tag_jpeg_detail_t *) detail;
-    if (swf_tag_jpeg == NULL) {
-        return ;
-    }
-    if (swf_tag_jpeg->jpeg_data) {
+    if (swf_tag_jpeg) {
         free(swf_tag_jpeg->jpeg_data);
-    }
-    if (swf_tag_jpeg->alpha_data) {
         free(swf_tag_jpeg->alpha_data);
+        swf_tag_jpeg->jpeg_data = NULL;
+        swf_tag_jpeg->alpha_data = NULL;
+        free(swf_tag_jpeg);
     }
-    free(swf_tag_jpeg);
     return ;
 }
     

Modified: src/swf_tag_lossless.c
===================================================================
--- src/swf_tag_lossless.c	2008-10-02 08:38:46 UTC (rev 52)
+++ src/swf_tag_lossless.c	2008-10-02 09:27:13 UTC (rev 53)
@@ -290,6 +290,11 @@
         free(swf_tag_lossless->indices);
         free(swf_tag_lossless->bitmap);
         free(swf_tag_lossless->bitmap2);
+        swf_tag_lossless->colormap = NULL;
+        swf_tag_lossless->colormap2 = NULL;
+        swf_tag_lossless->indices = NULL;
+        swf_tag_lossless->bitmap = NULL;
+        swf_tag_lossless->bitmap2 = NULL;
         free(swf_tag_lossless);
     }
     return ;

Modified: src/swf_tag_sound.c
===================================================================
--- src/swf_tag_sound.c	2008-10-02 08:38:46 UTC (rev 52)
+++ src/swf_tag_sound.c	2008-10-02 09:27:13 UTC (rev 53)
@@ -147,8 +147,11 @@
 void
 swf_tag_sound_destroy_detail(void *detail) {
     swf_tag_sound_detail_t *swf_tag_sound = (swf_tag_sound_detail_t *) detail;
-    free(swf_tag_sound->sound_data);
-    free(swf_tag_sound);
+    if (swf_tag_sound) {
+        free(swf_tag_sound->sound_data);
+        swf_tag_sound->sound_data = NULL;
+        free(swf_tag_sound);
+    }
     return ;
 }
 


Swfed-svn メーリングリストの案内
Back to archive index