[Swfed-svn] swfed-svn [158] エラー時の中断処理を追加

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2009年 6月 19日 (金) 00:57:05 JST


Revision: 158
          http://sourceforge.jp/projects/swfed/svn/view?view=rev&revision=158
Author:   yoya
Date:     2009-06-19 00:57:05 +0900 (Fri, 19 Jun 2009)

Log Message:
-----------
エラー時の中断処理を追加

Modified Paths:
--------------
    trunk/src/swf_line_style.c
    trunk/src/swf_line_style_array.c
    trunk/src/swf_shape_with_style.c
    trunk/src/swf_styles.c


-------------- next part --------------
Modified: trunk/src/swf_line_style.c
===================================================================
--- trunk/src/swf_line_style.c	2009-06-09 16:27:34 UTC (rev 157)
+++ trunk/src/swf_line_style.c	2009-06-18 15:57:05 UTC (rev 158)
@@ -5,8 +5,13 @@
 int
 swf_line_style_parse(bitstream_t *bs, swf_line_style_t *line_style,
                      swf_tag_t *tag) {
+    int result;
     if (tag->tag == 46) { // DefineMorphShape
-        line_style->width = bitstream_getbytesLE(bs, 2);
+        result = bitstream_getbytesLE(bs, 2);
+        if (result == -1) {
+            return 1;
+        }
+        line_style->width = result;
         line_style->width_morph = bitstream_getbytesLE(bs, 2);
         swf_rgba_parse(bs, &(line_style->rgba));
         swf_rgba_parse(bs, &(line_style->rgba_morph));
@@ -15,7 +20,11 @@
         if (tag->tag == 84) { // DefineMorphShape2
             line_style->width_morph = bitstream_getbytesLE(bs, 2);
         }
-        line_style->start_cap_style = bitstream_getbits(bs, 2);
+        result = bitstream_getbits(bs, 2);
+        if (result == -1) {
+            return 1;
+        }
+        line_style->start_cap_style = result;
         line_style->join_style = bitstream_getbits(bs, 2);
         line_style->has_fill = bitstream_getbits(bs, 1);
         line_style->no_hscale = bitstream_getbits(bs, 1);
@@ -36,10 +45,18 @@
             }
         }
     } else if (tag->tag == 32) { // DefineShape3
-        line_style->width = bitstream_getbytesLE(bs, 2);
+        result = bitstream_getbytesLE(bs, 2);
+        if (result == -1) {
+            return 1;
+        }
+        line_style->width = result;
         swf_rgba_parse(bs, &(line_style->rgba));
     } else {
-        line_style->width = bitstream_getbytesLE(bs, 2);
+        result = bitstream_getbytesLE(bs, 2);
+        if (result == -1) {
+            return 1;
+        }
+        line_style->width = result;
         swf_rgb_parse(bs, &(line_style->rgb));
     }
     return 0;

Modified: trunk/src/swf_line_style_array.c
===================================================================
--- trunk/src/swf_line_style_array.c	2009-06-09 16:27:34 UTC (rev 157)
+++ trunk/src/swf_line_style_array.c	2009-06-18 15:57:05 UTC (rev 158)
@@ -8,14 +8,34 @@
                            swf_line_style_array_t *shape_with_style,
                            swf_tag_t *tag) {
     int i;
-    shape_with_style->count = bitstream_getbyte(bs);
+    int result;
+    result = bitstream_getbyte(bs);
+    if (result == -1) {
+        fprintf(stderr, "swf_line_style_array_parse: bitstream_getbyte failed at (L%d)\n", __LINE__);
+        return 1;
+    }
+    shape_with_style->count = result;
     if ((tag->tag != 2) && // ! DefineShape
          (shape_with_style->count == 255)) {
-        shape_with_style->count = bitstream_getbytesLE(bs, 2);
+        result = bitstream_getbytesLE(bs, 2);
+        if (result == -1) {
+            fprintf(stderr, "swf_line_style_array_parse: bitstream_getbyte failed at (L%d)\n", __LINE__);
+            return 1;
+        }
+        shape_with_style->count = result;
     }
+    if (1000 < shape_with_style->count) { // XXX
+        fprintf(stderr, "swf_line_style_array_parse: too many count(%d)\n",
+                shape_with_style->count);
+        return 1;
+    }
     shape_with_style->line_style = calloc(shape_with_style->count, sizeof(swf_line_style_t));
     for (i = 0 ; i < shape_with_style->count ; i++) {
-        swf_line_style_parse(bs, &(shape_with_style->line_style[i]), tag);
+        result = swf_line_style_parse(bs, &(shape_with_style->line_style[i]), tag);
+        if (result) {
+            shape_with_style->count = i; // XXX
+            return result;
+        }
     }
     return 0;
 }

Modified: trunk/src/swf_shape_with_style.c
===================================================================
--- trunk/src/swf_shape_with_style.c	2009-06-09 16:27:34 UTC (rev 157)
+++ trunk/src/swf_shape_with_style.c	2009-06-18 15:57:05 UTC (rev 158)
@@ -6,10 +6,15 @@
 swf_shape_with_style_parse(bitstream_t *bs,
                            swf_shape_with_style_t *shape_with_style,
                            swf_tag_t *tag) {
-    swf_styles_parse(bs, &(shape_with_style->styles), tag);
-    swf_shape_record_parse(bs, &(shape_with_style->shape_records), tag,
-                           &(shape_with_style->styles.styles_count));
-    return 0;
+    int result;
+    result = swf_styles_parse(bs, &(shape_with_style->styles), tag);
+    if (result) {
+        return result;
+    }
+    result = swf_shape_record_parse(bs, &(shape_with_style->shape_records),
+                                    tag,
+                                    &(shape_with_style->styles.styles_count));
+    return result;
 }
 
 int

Modified: trunk/src/swf_styles.c
===================================================================
--- trunk/src/swf_styles.c	2009-06-09 16:27:34 UTC (rev 157)
+++ trunk/src/swf_styles.c	2009-06-18 15:57:05 UTC (rev 158)
@@ -5,10 +5,19 @@
 int
 swf_styles_parse(bitstream_t *bs, swf_styles_t *shape_with_style,
                  swf_tag_t *tag) {
-    swf_fill_style_array_parse(bs, &(shape_with_style->fill_styles), tag);
-    swf_line_style_array_parse(bs, &(shape_with_style->line_styles), tag);
-    swf_styles_count_parse(bs, &(shape_with_style->styles_count));
-    return 0;
+    int result;
+    result = swf_fill_style_array_parse(bs, &(shape_with_style->fill_styles),
+                                        tag);
+    if (result) {
+        return result;
+    }
+    result = swf_line_style_array_parse(bs, &(shape_with_style->line_styles),
+                                        tag);
+    if (result) {
+        return result;
+    }
+    result = swf_styles_count_parse(bs, &(shape_with_style->styles_count));
+    return result;
 }
 
 int



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