swf_tag_t *tag) {
int i;
fill_style_array->count = bitstream_getbyte(bs);
- if (tag->tag != 2 && // ! DefineShape
- fill_style_array->count == 255) {
+ if ((tag->tag != 2) && // ! DefineShape
+ (fill_style_array->count == 255)) {
fill_style_array->count = bitstream_getbytesLE(bs, 2);
}
fill_style_array->fill_style = calloc(fill_style_array->count, sizeof(swf_fill_style_t));
swf_fill_style_array_t *fill_style_array,
swf_tag_t *tag) {
int i;
- if (tag->tag != 2 && // ! DefineShape
- 255 <= fill_style_array->count) {
+ if ((tag->tag != 2) || // ! DefineShape
+ (255 <= fill_style_array->count)) {
bitstream_putbyte(bs, 255);
bitstream_putbytesLE(bs, fill_style_array->count, 2);
} else {
swf_tag_t *tag) {
int i;
shape_with_style->count = bitstream_getbyte(bs);
- if (tag->tag != 2 || // ! DefineShape
- shape_with_style->count == 255) {
+ if ((tag->tag != 2) && // ! DefineShape
+ (shape_with_style->count == 255)) {
shape_with_style->count = bitstream_getbytesLE(bs, 2);
}
shape_with_style->line_style = calloc(shape_with_style->count, sizeof(swf_line_style_t));
int
swf_line_style_array_build(bitstream_t *bs, swf_line_style_array_t *shape_with_style, swf_tag_t *tag) {
int i;
- if (tag->tag != 2 || // ! DefineShape
- 255 <= shape_with_style->count) {
+ if ((tag->tag != 2) || // ! DefineShape
+ (255 <= shape_with_style->count)) {
bitstream_putbyte(bs, 255);
bitstream_putbytesLE(bs, shape_with_style->count, 2);
} else {
swf_line_style_array_print(swf_line_style_array_t *shape_with_style, int indent_depth, swf_tag_t *tag) {
int i;
print_indent(indent_depth);
- printf("count=%u\n", shape_with_style->count);
+ printf("shape_with_style->count=%u\n", shape_with_style->count);
for (i = 0 ; i < shape_with_style->count ; i++) {
swf_line_style_print(&(shape_with_style->line_style[i]),
indent_depth + 1, tag);
swf_tag_t *tag, swf_styles_count_t *count) {
int first_bit, next_5bits;
swf_shape_record_t *current = shape_record;
- while (current) {
+ int limit;
+ for (limit = 1; current ; limit ++) {
shape_record->first_6bits = bitstream_getbits(bs, 6);
first_bit = (shape_record->first_6bits >> 5) & 1;
next_5bits = shape_record->first_6bits & 0x1f;
} else {
swf_shape_record_edge_parse(bs, &(current->shape_edge));
}
- current->next = calloc(1, sizeof(*current));
+ if (100 <= limit) {
+ current->next = NULL;
+ fprintf(stderr, "swf_shape_record_parse: limit over\n", limit);
+ return 1;
+ }
+ current->next = calloc(1, sizeof(swf_shape_record_t));
current = current->next;
+ current->next = NULL; // fail safe
}
return 0;
}
swf_tag_t *tag, swf_styles_count_t *count) {
int first_bit, next_5bits;
swf_shape_record_t *current = shape_record;
- while (current) {
+ int i;
+ for (i = 0 ; current ; i++) {
first_bit = (shape_record->first_6bits >> 5) & 1;
next_5bits = shape_record->first_6bits & 0x1f;
+ print_indent(indent_depth);
+ printf("shape_record [%d]\n", i);
if ((first_bit == 0) && (next_5bits == 0)) {
swf_shape_record_end_print(&(current->shape_end), indent_depth);
break;
}
return 0;
}
+