[Swfed-svn] swfed-svn [434] - NULL チェック

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2011年 3月 17日 (木) 16:11:27 JST


Revision: 434
          http://sourceforge.jp/projects/swfed/svn/view?view=rev&revision=434
Author:   yoya
Date:     2011-03-17 16:11:26 +0900 (Thu, 17 Mar 2011)

Log Message:
-----------
- NULL チェック
- free 前に危ないメンバに NULL 代入

Modified Paths:
--------------
    trunk/src/swf_object.c


-------------- next part --------------
Modified: trunk/src/swf_object.c
===================================================================
--- trunk/src/swf_object.c	2011-03-17 05:57:13 UTC (rev 433)
+++ trunk/src/swf_object.c	2011-03-17 07:11:26 UTC (rev 434)
@@ -43,6 +43,7 @@
             next_tag = tag->next;
             swf_tag_destroy(tag);
         }
+        swf->tag = NULL;
         free(swf);
     }
     malloc_debug_end(); /* DEBUG XXX */
@@ -133,10 +134,19 @@
 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 @@
 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 @@
         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 @@
         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 @@
         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 @@
         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 @@
         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_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;



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