Language: C
Label: safe
CWE: CWE-369 \u2014 Divide By Zero
The product divides a value by zero.

Code:
GF_Err gf_swf_read_header(SWFReader *read)
{
	SWFRec rc;
	u8 sig[3];

	/*get signature*/
	sig[0] = gf_bs_read_u8(read->bs);
	sig[1] = gf_bs_read_u8(read->bs);
	sig[2] = gf_bs_read_u8(read->bs);
	/*"FWS" or "CWS"*/
	if ( ((sig[0] != 'F') && (sig[0] != 'C')) || (sig[1] != 'W') || (sig[2] != 'S') ) {
		return GF_NON_COMPLIANT_BITSTREAM;
	}
	/*version = */gf_bs_read_u8(read->bs);
	read->length = swf_get_32(read);

	/*if compressed decompress the whole file*/
	if (sig[0] == 'C') {
		swf_init_decompress(read);
		if (!read->bs) return GF_NON_COMPLIANT_BITSTREAM;
	}

	swf_get_rec(read, &rc);
	read->width = rc.w;
	read->height = rc.h;

	swf_align(read);
	read->frame_rate = swf_get_16(read)>>8;
	read->frame_count = swf_get_16(read);
	GF_LOG(GF_LOG_INFO, GF_LOG_PARSER, ("SWF Import - Scene Size %gx%g - %d frames @ %d FPS\n", read->width, read->height, read->frame_count, read->frame_rate));
	if (!read->frame_rate) read->frame_rate = 1;
	return GF_OK;
}