jpegconv_std2swf(unsigned char *data, unsigned long data_len,
unsigned long *length) {
jpeg_segment_t *jpeg_data = NULL;
- jpeg_segment_t *jpeg_output;
- unsigned char *d;
+ jpeg_segment_t *jpeg_output = NULL;
+ unsigned char *d = NULL;
unsigned long d_len;
int m;
unsigned char *ret_data;
+ if (data == NULL) {
+ fprintf(stderr, "jpegconv_std2swf: data == NULL\n");
+ return NULL;
+ }
jpeg_data = jpeg_segment_parse(data, data_len, 1);
if (jpeg_data == NULL) {
fprintf(stderr, "jpegconv_std2swf: Can't create jpeg segment for data\n");
jpegconv_swf2std(unsigned char *data, unsigned long data_len,
unsigned long *length, unsigned char *table_data,
unsigned long table_data_len) {
- jpeg_segment_t *jpeg_data, *jpeg_table = NULL;
- jpeg_segment_t *jpeg_output;
+ jpeg_segment_t *jpeg_data = NULL, *jpeg_table = NULL;
+ jpeg_segment_t *jpeg_output = NULL;
int m;
- unsigned char *d;
+ unsigned char *d = NULL;
unsigned long d_len;
- unsigned char *ret_data;
+ unsigned char *ret_data = NULL;
*length = 0;
+ if (data == NULL) {
+ fprintf(stderr, "jpegconv_swf2std: data == NULL\n");
+ return NULL;
+ }
jpeg_data = jpeg_segment_parse(data, data_len, 1);
if (jpeg_data == NULL) {
fprintf(stderr, "jpegconv_swf2std: Can't create jpeg segment for data\n");
png_uint_32 png_width = 0, png_height = 0;
volatile png_bytepp png_image_data = NULL;
png_uint_32 x, y;
- void *image_data;
+ void *image_data = NULL;
png_color *palette = NULL;
int palette_num = 0;
png_bytep trans = NULL;
int num_trans = 0;
png_color_16p trans_values = NULL;
+ if (png_data == NULL) {
+ fprintf(stderr, "pngconv_png2lossless: png_data == NULL\n");
+ return NULL;
+ }
is_png = png_check_sig((png_bytep)png_data, 8);
if (! is_png) {
fprintf(stderr, "pngconv_png2lossless: is not PNG!\n");
volatile png_bytepp png_image_data = NULL;
png_uint_32 x, y;
volatile png_colorp png_palette = NULL;
+ if (image_data == NULL) {
+ fprintf(stderr, "pngconv_lossless2png: image_data == NULL\n");
+ return NULL;
+ }
if ((format != 3) && (format != 5)) {
fprintf(stderr, "jpegconv_lossless2png: format=%d not implemented yes.\n", format);
return NULL;
}
swf_tag_t *swf_tag_create(bitstream_t *bs) {
- swf_tag_t *tag = calloc(sizeof(*tag), 1);
+ swf_tag_t *tag = NULL;
unsigned short tag_and_length;
if (bs == NULL) {
fprintf(stderr, "swf_tag_create: bs == NULL\n");
return NULL;
}
+ tag = calloc(sizeof(*tag), 1);
tag_and_length = bitstream_getbytesLE(bs, 2);
if (tag_and_length == (unsigned short) -1) {
fprintf(stderr, "swf_tag_create: tag_and_length(short) == -1\n");
fprintf(stderr, "swf_tag_and_length_build: bs == NULL\n");
return 1;
}
+ if (tag == NULL) {
+ fprintf(stderr, "swf_tag_and_length_build: tag == NULL\n");
+ return 1;
+ }
if (tag->length >= 0x3f) {
tag->length_longformat = 1;
} else {
}
int swf_tag_build(bitstream_t *bs, swf_tag_t *tag, struct swf_object_ *swf) {
- swf_tag_info_t *tag_info;
- unsigned char *data;
+ swf_tag_info_t *tag_info = NULL;
+ unsigned char *data = NULL;
unsigned long data_len = 0;
- swf_tag_detail_handler_t * detail_handler;
+ swf_tag_detail_handler_t * detail_handler = NULL;
if (bs == NULL) {
fprintf(stderr, "swf_tag_and_length_build: bs == NULL\n");
return 1;
}
+ if (tag == NULL) {
+ fprintf(stderr, "swf_tag_and_length_build: tag == NULL\n");
+ return 1;
+ }
// fprintf(stderr, "XXX: swf_tag_build: tag->tag=%d\n",tag->tag);
if (tag->data) {
swf_tag_and_length_build(bs, tag);
void
swf_tag_print(swf_tag_t *tag, struct swf_object_ *swf, int indent_depth) {
- swf_tag_info_t *tag_info;
- const char *tag_name;
+ swf_tag_info_t *tag_info = NULL;
+ const char *tag_name = NULL;
if (tag == NULL) {
fprintf(stderr, "swf_tag_print: tag == NULL\n");
return ;
}
int swf_tag_create_input_detail(swf_tag_t *tag, struct swf_object_ *swf) {
- swf_tag_info_t *tag_info;
+ swf_tag_info_t *tag_info = NULL;
if (tag == NULL) {
fprintf(stderr, "swf_tag_create_input_detail: tag == NULL\n");
return 1;
int
swf_tag_get_cid(swf_tag_t *tag) {
- swf_tag_info_t *tag_info;
- int tag_no = tag->tag;
+ swf_tag_info_t *tag_info = NULL;
+ int tag_no;
+ if (tag == NULL) {
+ fprintf(stderr, "swf_tag_get_cid: tag == NULL\n");
+ return 1;
+ }
+ tag_no = tag->tag;
tag_info = get_swf_tag_info(tag_no);
if (tag_info && tag_info->detail_handler) {
swf_tag_detail_handler_t * detail_handler = tag_info->detail_handler();
int
swf_tag_replace_cid(swf_tag_t *tag, int cid) {
swf_tag_info_t *tag_info;
- int tag_no = tag->tag;
+ int tag_no;
+ if (tag == NULL) {
+ fprintf(stderr, "swf_tag_replace_cid: tag == NULL\n");
+ return 1; // failure
+ }
+ tag_no = tag->tag;
tag_info = get_swf_tag_info(tag_no);
if (tag_info && tag_info->detail_handler) {
swf_tag_detail_handler_t * detail_handler = tag_info->detail_handler();
int
swf_tag_get_refcid(swf_tag_t *tag) {
+ if (tag == NULL) {
+ fprintf(stderr, "swf_tag_get_refcid: tag == NULL\n");
+ return -1;
+ }
if (isPlaceTag(tag->tag)) { // PlaceObject, PlaceObject2
swf_tag_place_detail_t *swf_tag_place;
if (! tag->detail) {
int
swf_tag_replace_refcid(swf_tag_t *tag, int cid) {
// fprintf(stderr, "XXX: swf_tag_replace_refcid(tag(code=%d), cid(%d))\n", tag->tag, cid);
+ if (tag == NULL) {
+ fprintf(stderr, "swf_tag_replace_refcid: tag == NULL\n");
+ return 1; // failure
+ }
if (isPlaceTag(tag->tag)) { // PlaceObject, PlaceObject2
swf_tag_place_detail_t *swf_tag_place;
if (! tag->detail) {
free(tag->data);
tag->data = NULL;
}
- return 0; // always 0;
+ return 0; // success
}
/* bitmap */
fprintf(stderr, "swf_tag_get_bitmap_size: tag == NULL\n");
return 1;
}
+ if ((width == NULL ) || (height == NULL)) {
+ fprintf(stderr, "swf_tag_get_bitmap_size: width == NULL or height == NULL\n");
+ return 1;
+ }
if (tag->detail == NULL) {
swf_tag_create_input_detail(tag, NULL);
}
swf_tag_lossless_detail_t *swf_tag_lossless = (swf_tag_lossless_detail_t *) tag->detail;
*width = swf_tag_lossless->width;
*height = swf_tag_lossless->height;
+ } else { // no Bitmap Tag
+ return 1;
}
return ret;
unsigned char *
swf_tag_get_jpeg_data(swf_tag_t *tag, unsigned long *length, int image_id, swf_tag_t *tag_jpegtables) {
- swf_tag_info_t *tag_info;
+ swf_tag_info_t *tag_info = NULL;
*length = 0;
if (tag == NULL) {
fprintf(stderr, "swf_tag_get_jpeg_data: tag == NULL\n");
return NULL;
}
+ if (length == NULL) {
+ fprintf(stderr, "swf_tag_get_jpeg_data: length == NULL\n");
+ return NULL;
+ }
tag_info = get_swf_tag_info(tag->tag);
if ((tag->tag != 6) && (tag->tag != 21) && (tag->tag != 35)) {
return NULL;
fprintf(stderr, "swf_tag_get_alpha_data: tag == NULL\n");
return NULL;
}
+ if (length == NULL) {
+ fprintf(stderr, "swf_tag_get_alpha_data: length == NULL\n");
+ return NULL;
+ }
if (tag->tag != 35) { // ! DefineBitsJPEG3
return NULL;
}
unsigned long jpeg_data_len,
unsigned char *alpha_data,
unsigned long alpha_data_len) {
- swf_tag_info_t *tag_info;
- swf_tag_detail_handler_t * detail_handler;
+ swf_tag_info_t *tag_info = NULL;
+ swf_tag_detail_handler_t * detail_handler = NULL;
int result;
if (tag == NULL) {
fprintf(stderr, "swf_tag_replace_jpeg_data: tag == NULL\n");
return 1;
}
+ if (jpeg_data == NULL) {
+ fprintf(stderr, "swf_tag_replace_jpeg_data: jpeg_data == NULL\n");
+ return 1;
+ }
if (! isBitmapTag(tag->tag)) {
return 1;
}
unsigned char *
swf_tag_get_png_data(swf_tag_t *tag, unsigned long *length, int image_id) {
- swf_tag_info_t *tag_info;
+ swf_tag_info_t *tag_info = NULL;
*length = 0;
if (tag == NULL) {
fprintf(stderr, "swf_tag_get_png_data: tag == NULL\n");
return NULL;
}
+ if (length == NULL) {
+ fprintf(stderr, "swf_tag_get_png_data: length == NULL\n");
+ return NULL;
+ }
tag_info = get_swf_tag_info(tag->tag);
if ((tag->tag != 20) && (tag->tag != 36)) {
return NULL;
swf_tag_replace_png_data(swf_tag_t *tag, int image_id,
unsigned char *png_data,
unsigned long png_data_len) {
- swf_tag_info_t *tag_info;
- swf_tag_detail_handler_t *detail_handler;
+ swf_tag_info_t *tag_info = NULL;
+ swf_tag_detail_handler_t *detail_handler = NULL;
int result;
if (tag == NULL) {
fprintf(stderr, "swf_tag_replace_png_data: tag == NULL\n");
return 1;
}
+ if (png_data == NULL) {
+ fprintf(stderr, "swf_tag_replace_png_data: png_data == NULL\n");
+ return 1;
+ }
if (! isBitmapTag(tag->tag)) {
return 1;
}
swf_tag_replace_gif_data(swf_tag_t *tag, int image_id,
unsigned char *gif_data,
unsigned long gif_data_len) {
- swf_tag_info_t *tag_info;
- swf_tag_detail_handler_t *detail_handler;
+ swf_tag_info_t *tag_info = NULL;
+ swf_tag_detail_handler_t *detail_handler = NULL;
int result;
if (tag == NULL) {
fprintf(stderr, "swf_tag_replace_gif_data: tag == NULL\n");
return 1;
}
+ if (gif_data == NULL) {
+ fprintf(stderr, "swf_tag_replace_gif_data: gif_data == NULL\n");
+ return 1;
+ }
if (! isBitmapTag(tag->tag)) {
return 1;
}
unsigned char *
swf_tag_get_sound_data(swf_tag_t *tag, unsigned long *length, int sound_id) {
- swf_tag_info_t *tag_info;
+ swf_tag_info_t *tag_info = NULL;
*length = 0;
if (tag == NULL) {
fprintf(stderr, "swf_tag_get_sound_data: tag == NULL\n");
return NULL;
}
+ if (length == NULL) {
+ fprintf(stderr, "swf_tag_get_sound_data: length == NULL\n");
+ return NULL;
+ }
tag_info = get_swf_tag_info(tag->tag);
if (tag->tag != 14) { // DefineSound
return NULL;
fprintf(stderr, "swf_tag_replace_melo_data: tag == NULL\n");
return 1;
}
+ if (melo_data == NULL) {
+ fprintf(stderr, "swf_tag_replace_melo_data: melo_data == NULL\n");
+ return 1;
+ }
if (tag->tag != 14) { // DefineSound
return 1;
}
return result;
}
+
char *
swf_tag_get_edit_string(swf_tag_t *tag,
char *variable_name, int variable_name_len,
fprintf(stderr, "swf_tag_get_edit_string: tag == NULL\n");
return NULL;
}
+ if (variable_name == NULL) {
+ fprintf(stderr, "swf_tag_get_edit_string: variable_name == NULL\n");
+ return NULL;
+ }
if (tag->tag != 37) { // DefineEditText
return NULL;
}
fprintf(stderr, "swf_tag_replace_edit_string: tag == NULL\n");
return 1;
}
+ if (variable_name == NULL) {
+ fprintf(stderr, "swf_tag_replace_edit_string: variable_name == NULL\n");
+ return 1;
+ }
if (tag->tag != 37) { // DefineEditText
return 1;
}
return result;
}
-
int
swf_tag_apply_shape_matrix_factor(swf_tag_t *tag, int shape_id,
double scale_x, double scale_y,
tag->length = 0;
}
return result;
-
}
swf_tag_t *
swf_tag_create_action_setvariables(y_keyvalue_t *kv) {
int ret;
- swf_tag_t *tag = calloc(sizeof(*tag), 1);
+ swf_tag_t *tag = NULL;
+ if (kv == NULL) {
+ fprintf(stderr, "swf_tag_create_action_setvariables: kv == NULL\n");
+ return NULL;
+ }
+ tag = calloc(sizeof(*tag), 1);
tag->tag = 12; // DoAction
swf_tag_info_t *tag_info = get_swf_tag_info(tag->tag);
swf_tag_detail_handler_t *detail_handler = tag_info->detail_handler();
swf_tag_put_action_setvariables(swf_tag_t *tag, y_keyvalue_t *kv,
struct swf_object_ *swf) {
int ret;
+ if (tag == NULL) {
+ fprintf(stderr, "swf_tag_put_action_setvariables: tag == NULL\n");
+ return 1;
+ }
+ if (kv == NULL) {
+ fprintf(stderr, "swf_tag_put_action_setvariables: kv == NULL\n");
+ return 1;
+ }
if (! tag->detail) {
swf_tag_create_input_detail(tag, swf);
}
}
extern swf_tag_t * swf_tag_move(swf_tag_t *from_tag) {
- swf_tag_t *to_tag = calloc(sizeof(*to_tag), 1);
+ swf_tag_t *to_tag = NULL;
+ if (from_tag == NULL) {
+ fprintf(stderr, "swf_tag_move: from_tag == NULL\n");
+ return NULL;
+ }
+ to_tag = calloc(sizeof(*to_tag), 1);
to_tag->tag = from_tag->tag;
to_tag->length = from_tag->length;
to_tag->length_longformat = from_tag->length_longformat;
int
swf_tag_jpeg_input_detail(swf_tag_t *tag,
struct swf_object_ *swf) {
- swf_tag_jpeg_detail_t *swf_tag_jpeg = tag->detail;
- unsigned char *data = tag->data;
- unsigned long length = tag->length;
- bitstream_t *bs;
+ swf_tag_jpeg_detail_t *swf_tag_jpeg = NULL;
+ unsigned char *data = NULL;
+ unsigned long length;
+ bitstream_t *bs = NULL;
(void) swf;
+ if (tag == NULL) {
+ fprintf(stderr, "ERROR: swf_tag_jpeg_input_detail: swf_tag_jpeg == NULL\n");
+ return 1;
+ }
+ swf_tag_jpeg = tag->detail;
+ data = tag->data;
+ length = tag->length;
if (swf_tag_jpeg == NULL) {
fprintf(stderr, "ERROR: swf_tag_jpeg_input_detail: swf_tag_jpeg == NULL\n");
return 1;
int
swf_tag_jpegt_input_detail(swf_tag_t *tag,
struct swf_object_ *swf) {
- swf_tag_jpeg_detail_t *swf_tag_jpeg = tag->detail;
- unsigned char *data = tag->data;
- unsigned long length = tag->length;
+ swf_tag_jpeg_detail_t *swf_tag_jpeg = NULL;
+ unsigned char *data = NULL;
+ unsigned long length;
(void) swf;
+ if (tag == NULL) {
+ fprintf(stderr, "ERROR: swf_tag_jpegt_input_detail: tag == NULL\n");
+ return 1;
+ }
+ swf_tag_jpeg = tag->detail;
+ data = tag->data;
+ length = tag->length;
if (swf_tag_jpeg == NULL) {
fprintf(stderr, "ERROR: swf_tag_jpegt_input_detail: swf_tag_jpeg == NULL\n");
return 1;
int
swf_tag_jpeg3_input_detail(swf_tag_t *tag,
struct swf_object_ *swf) {
- swf_tag_jpeg_detail_t *swf_tag_jpeg = tag->detail;
- unsigned char *data = tag->data;
- unsigned long length = tag->length;
+ swf_tag_jpeg_detail_t *swf_tag_jpeg = NULL;
+ unsigned char *data = NULL;
+ unsigned long length;
unsigned long offset_to_alpha;
- bitstream_t *bs;
+ bitstream_t *bs = NULL;
unsigned long offset, alpha_data_len;
- unsigned char *old_buff_ref, *new_buff;
+ unsigned char *old_buff_ref = NULL, *new_buff = NULL;
unsigned long origsize;
int result;
(void) swf;
+ if (tag == NULL) {
+ fprintf(stderr, "swf_tag_jpeg3_input_detail: tag == NULL\n");
+ return 1;
+ }
+ swf_tag_jpeg = tag->detail;
+ data = tag->data;
+ length = tag->length;
if (swf_tag_jpeg == NULL) {
fprintf(stderr, "ERROR: swf_tag_jpeg3_input_detail: swf_tag_jpeg == NULL\n");
return 1;
int
swf_tag_jpeg_get_cid_detail(swf_tag_t *tag) {
- unsigned char *data = tag->data;
+ unsigned char *data = NULL;
+
+ if (tag == NULL) {
+ fprintf(stderr, "swf_tag_jpeg_get_cid_detail: tag == NULL\n");
+ return -1;
+ }
+ data = tag->data;
if (tag->detail) {
swf_tag_jpeg_detail_t *swf_tag_jpeg = (swf_tag_jpeg_detail_t *) tag->detail;
return swf_tag_jpeg->image_id;
}
int
swf_tag_jpeg_replace_cid_detail(swf_tag_t *tag, int image_id) {
- unsigned char *data = tag->data;
+ unsigned char *data = NULL;
+ if (tag == NULL) {
+ fprintf(stderr, "swf_tag_jpeg_replace_cid_detail: tag == NULL\n");
+ return 1;
+ }
+ data = tag->data;
if (tag->detail) {
swf_tag_jpeg_detail_t *swf_tag_jpeg = (swf_tag_jpeg_detail_t *) tag->detail;
swf_tag_jpeg->image_id = image_id;
if (data) {
PutUShortLE(data, image_id);
}
- return 0; // always 0
+ return 0;
}
unsigned char *
swf_tag_jpeg_output_detail(swf_tag_t *tag, unsigned long *length,
struct swf_object_ *swf) {
- swf_tag_jpeg_detail_t *swf_tag_jpeg = (swf_tag_jpeg_detail_t *) tag->detail;
- bitstream_t *bs;
- unsigned char *data;
+ swf_tag_jpeg_detail_t *swf_tag_jpeg = NULL;
+ bitstream_t *bs = NULL;
+ unsigned char *data = NULL;
(void) swf;
+ if (tag == NULL) {
+ fprintf(stderr, "swf_tag_jpeg_output_detail: tag == NULL\n");
+ return NULL;
+ }
+ swf_tag_jpeg = (swf_tag_jpeg_detail_t *) tag->detail;
*length = 0;
bs = bitstream_open();
bitstream_putbytesLE(bs, swf_tag_jpeg->image_id, 2);
unsigned char *
swf_tag_jpegt_output_detail(swf_tag_t *tag, unsigned long *length,
struct swf_object_ *swf) {
- swf_tag_jpeg_detail_t *swf_tag_jpeg = (swf_tag_jpeg_detail_t *) tag->detail;
- bitstream_t *bs;
- unsigned char *data;
+ swf_tag_jpeg_detail_t *swf_tag_jpeg = NULL;
+ bitstream_t *bs = NULL;
+ unsigned char *data = NULL;
(void) swf;
+ if (tag == NULL) {
+ fprintf(stderr, "swf_tag_jpegt_output_detail: tag == NULL\n");
+ return NULL;
+ }
+ if (length == NULL) {
+ fprintf(stderr, "swf_tag_jpegt_output_detail: length == NULL\n");
+ return NULL;
+ }
*length = 0;
+ swf_tag_jpeg = (swf_tag_jpeg_detail_t *) tag->detail;
bs = bitstream_open();
bitstream_putstring(bs, swf_tag_jpeg->jpeg_data, swf_tag_jpeg->jpeg_data_len);
data = bitstream_steal(bs, length);
unsigned char *
swf_tag_jpeg3_output_detail(swf_tag_t *tag, unsigned long *length,
struct swf_object_ *swf) {
- swf_tag_jpeg_detail_t *swf_tag_jpeg = (swf_tag_jpeg_detail_t *) tag->detail;
- bitstream_t *bs;
- unsigned char *data, *new_buff;
+ swf_tag_jpeg_detail_t *swf_tag_jpeg = NULL;
+ bitstream_t *bs = NULL;
+ unsigned char *data = NULL, *new_buff = NULL;
unsigned long offset_to_alpha;
unsigned long compsize, old_size;
int result;
(void) swf;
+ if (tag == NULL) {
+ fprintf(stderr, "swf_tag_jpeg3_output_detail: tag == NULL\n");
+ }
+ if (length == NULL) {
+ fprintf(stderr, "swf_tag_jpeg3_output_detail: length == NULL\n");
+ }
+ swf_tag_jpeg = (swf_tag_jpeg_detail_t *) tag->detail;
*length = 0;
bs = bitstream_open();
bitstream_putbytesLE(bs, swf_tag_jpeg->image_id, 2);
void
swf_tag_jpeg_print_detail(swf_tag_t *tag,
struct swf_object_ *swf, int indent_depth) {
- swf_tag_jpeg_detail_t *swf_tag_jpeg = (swf_tag_jpeg_detail_t *) tag->detail;
- jpeg_segment_t *jpeg_seg;
- jpeg_segment_node_t *node;
+ swf_tag_jpeg_detail_t *swf_tag_jpeg = NULL;
+ jpeg_segment_t *jpeg_seg = NULL;
+ jpeg_segment_node_t *node = NULL;
(void) swf;
+ if (tag == NULL) {
+ fprintf(stderr, "swf_tag_jpeg_print_detail: tag == NULL\n");
+ return ;
+ }
+ swf_tag_jpeg = (swf_tag_jpeg_detail_t *) tag->detail;
if (swf_tag_jpeg == NULL) {
fprintf(stderr, "swf_tag_jpeg_print_detail: swf_tag_jpeg == NULL\n");
return ;
}
+
print_indent(indent_depth);
if (swf_tag_jpeg->image_id == -1) {
printf("jpeg_data_size=%lu\n", swf_tag_jpeg->jpeg_data_len);
void
swf_tag_jpeg_destroy_detail(swf_tag_t *tag) {
- swf_tag_jpeg_detail_t *swf_tag_jpeg = (swf_tag_jpeg_detail_t *) tag->detail;
+ swf_tag_jpeg_detail_t *swf_tag_jpeg = NULL;
+ if (tag == NULL) {
+ fprintf(stderr, "swf_tag_jpeg_destroy_detail: tag == NULL\n");
+ return ;
+ }
+ swf_tag_jpeg = (swf_tag_jpeg_detail_t *) tag->detail;
if (swf_tag_jpeg) {
free(swf_tag_jpeg->jpeg_data);
free(swf_tag_jpeg->alpha_data);
unsigned long jpeg_table_data_len) {
swf_tag_jpeg_detail_t *swf_tag_jpeg = (swf_tag_jpeg_detail_t *) detail;
unsigned char *data;
- *length = 0;
if (detail == NULL) {
fprintf(stderr, "swf_tag_jpeg_get_jpeg_data: detail == NULL\n");
}
+ if (length == NULL) {
+ fprintf(stderr, "swf_tag_jpeg_get_jpeg_data: length == NULL\n");
+ }
+ *length = 0;
if (swf_tag_jpeg->image_id != image_id) {
return NULL;
}
unsigned char *swf_tag_jpeg_get_alpha_data(void *detail, unsigned long *length, int image_id) {
swf_tag_jpeg_detail_t *swf_tag_jpeg = (swf_tag_jpeg_detail_t *) detail;
- unsigned char *data;
- *length = 0;
+ unsigned char *data = NULL;
if (detail == NULL) {
fprintf(stderr, "swf_tag_jpeg_get_alpha_data: detail == NULL\n");
return NULL;
}
+ if (length == NULL) {
+ fprintf(stderr, "swf_tag_jpeg_get_alpha_data: length == NULL\n");
+ return NULL;
+ }
+
+ *length = 0;
if (swf_tag_jpeg->image_id != image_id) {
return NULL;
}
int
swf_tag_lossless_input_detail(swf_tag_t *tag,
struct swf_object_ *swf) {
- swf_tag_lossless_detail_t *swf_tag_lossless = tag->detail;
- unsigned char *data = tag->data;
- unsigned long length = tag->length;
- bitstream_t *bs, *bs2;
- (void) swf;
+ swf_tag_lossless_detail_t *swf_tag_lossless = NULL;
+ unsigned char *data = NULL;
+ unsigned long length;
+ bitstream_t *bs = NULL, *bs2 = NULL;
unsigned long i;
- unsigned char *tmp_buff, *old_buff_ref;
+ unsigned char *tmp_buff = NULL, *old_buff_ref = NULL;
unsigned long origsize, old_size, offset;
int result;
- if (swf_tag_lossless == NULL) {
- fprintf(stderr, "swf_tag_lossless_input_detail: swf_tag_lossless == NULL\n");
+ (void) swf;
+ if (tag == NULL) {
+ fprintf(stderr, "swf_tag_lossless_input_detail: tag == NULL\n");
+ return 1;
+ }
+ if (tag->detail == NULL) {
+ fprintf(stderr, "swf_tag_lossless_input_detail: tag->detail== NULL\n");
return 1;
}
+ swf_tag_lossless = tag->detail;
+ data = tag->data;
+ length = tag->length;
bs = bitstream_open();
bitstream_input(bs, data, length);
int
swf_tag_lossless_get_cid_detail(swf_tag_t *tag) {
- unsigned char *data = tag->data;
+ unsigned char *data = NULL;
+ if (tag == NULL) {
+ fprintf(stderr, "swf_tag_lossless_get_cid_detail: tag == NULL\n");
+ return 1;
+ }
+ data = tag->data;
if (tag->detail) {
swf_tag_lossless_detail_t *swf_tag_lossless = (swf_tag_lossless_detail_t *) tag->detail;
return swf_tag_lossless->image_id;
int
swf_tag_lossless_replace_cid_detail(swf_tag_t *tag, int id) {
- unsigned char *data = tag->data;
+ unsigned char *data = NULL;
+ if (tag == NULL) {
+ fprintf(stderr, "swf_tag_lossless_replace_cid_detail: tag == NULL\n");
+ return 1;
+ }
+ data = tag->data;
if (tag->detail) {
swf_tag_lossless_detail_t *swf_tag_lossless = (swf_tag_lossless_detail_t *) tag->detail;
swf_tag_lossless->image_id = id;
swf_tag_lossless_output_detail(swf_tag_t *tag, unsigned long *length,
struct swf_object_ *swf) {
swf_tag_lossless_detail_t *swf_tag_lossless = (swf_tag_lossless_detail_t *) tag->detail;
- bitstream_t *bs, *bs2;
- unsigned char *data;
+ bitstream_t *bs = NULL, *bs2 = NULL;
+ unsigned char *data = NULL;
unsigned long i;
- unsigned char *tmp_buff, *old_buff_ref;
+ unsigned char *tmp_buff = NULL, *old_buff_ref = NULL;
unsigned long compsize, old_size;
int result;
(void) swf;
+ if (tag == NULL) {
+ fprintf(stderr, "swf_tag_lossless_output_detail: tag == NULL\n");
+ return NULL;
+ }
+ if (length == NULL) {
+ fprintf(stderr, "swf_tag_lossless_output_detail: length == NULL\n");
+ return NULL;
+ }
+
*length = 0;
bs = bitstream_open();
bitstream_putbytesLE(bs, swf_tag_lossless->image_id, 2);
void
swf_tag_lossless_print_detail(swf_tag_t *tag,
struct swf_object_ *swf, int indent_depth) {
- swf_tag_lossless_detail_t *swf_tag_lossless = (swf_tag_lossless_detail_t *) tag->detail;
+ swf_tag_lossless_detail_t *swf_tag_lossless = NULL;
(void) swf;
- if (swf_tag_lossless == NULL) {
- fprintf(stderr, "swf_tag_lossless_print_detail: swf_tag_lossless == NULL\n");
+ if (tag == NULL) {
+ fprintf(stderr, "swf_tag_lossless_print_detail: tag == NULL\n");
return ;
}
+ if (tag->detail == NULL) {
+ fprintf(stderr, "swf_tag_lossless_print_detail: tag->detail == NULL\n");
+ return ;
+ }
+ swf_tag_lossless = (swf_tag_lossless_detail_t *) tag->detail;
print_indent(indent_depth);
printf("image_id=%d format=%d width=%u height=%u\n",
swf_tag_lossless->image_id, swf_tag_lossless->format,
void
swf_tag_lossless_destroy_detail(swf_tag_t *tag) {
- swf_tag_lossless_detail_t *swf_tag_lossless = (swf_tag_lossless_detail_t *) tag->detail;
+ swf_tag_lossless_detail_t *swf_tag_lossless;
+ if (tag == NULL) {
+ fprintf(stderr, "swf_tag_lossless_destroy_detail: tag == NULL\n");
+ return ;
+ }
+ swf_tag_lossless = (swf_tag_lossless_detail_t *) tag->detail;
if (swf_tag_lossless) {
free(swf_tag_lossless->colormap);
free(swf_tag_lossless->colormap2);
#ifdef HAVE_PNG
unsigned char *swf_tag_lossless_get_png_data(void *detail,
- unsigned long *length,
+ unsigned long *length,
int image_id,
swf_tag_t *tag) {
- swf_tag_lossless_detail_t *swf_tag_lossless;
- unsigned char *data;
+ swf_tag_lossless_detail_t *swf_tag_lossless = (swf_tag_lossless_detail_t *) detail;
+ unsigned char *data = NULL;
*length = 0;
void *index_data = NULL;
void *image_data = NULL;
if (detail == NULL) {
fprintf(stderr, "swf_tag_lossless_get_lossless_data: detail == NULL at line(%d)\n", __LINE__);
+ return NULL;
+ }
+ if (length == NULL) {
+ fprintf(stderr, "swf_tag_lossless_get_lossless_data: length == NULL at line(%d)\n", __LINE__);
+ return NULL;
}
- swf_tag_lossless = (swf_tag_lossless_detail_t *) detail;
if (swf_tag_lossless->image_id != image_id) {
return NULL;
}
unsigned long png_data_len, swf_tag_t *tag) {
int tag_no, format;
unsigned short width, height;
- unsigned char *result_data;
+ unsigned char *result_data = NULL;
void *colormap = NULL;
int colormap_count = 0;
swf_tag_lossless_detail_t *swf_tag_lossless = (swf_tag_lossless_detail_t *) detail;
fprintf(stderr, "swf_tag_lossess_replace_png_data: detail == NULL at line(%d)\n", __LINE__);
return 1;
}
+ if (png_data == NULL) {
+ fprintf(stderr, "swf_tag_lossess_replace_png_data: png_data == NULL at line(%d)\n", __LINE__);
+ return 1;
+ }
swf_tag_lossless->image_id = image_id;
result_data = pngconv_png2lossless(png_data, png_data_len,
&tag_no, &format,
unsigned long gif_data_len, swf_tag_t *tag) {
int tag_no, format;
unsigned short width, height;
- unsigned char *result_data;
+ unsigned char *result_data = NULL;
void *colormap = NULL;
int colormap_count = 0;
swf_tag_lossless_detail_t *swf_tag_lossless = (swf_tag_lossless_detail_t *) detail;
fprintf(stderr, "swf_tag_lossless_replace_gif_data: detail == NULL at line(%d)\n", __LINE__);
return 1;
}
+ if (gif_data == NULL) {
+ fprintf(stderr, "swf_tag_lossless_replace_gif_data: gif_data == NULL at line(%d)\n", __LINE__);
+ return 1;
+ }
swf_tag_lossless->image_id = image_id;
result_data = gifconv_gif2lossless(gif_data, gif_data_len,
&tag_no, &format,