Language: C
Label: safe
CWE: CWE-476 \u2014 NULL Pointer Dereference
A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.

Code:
static void get_info_from_frame (mpeg2ps_stream_t *sptr,
                                 u8 *buffer,
                                 u32 buflen)
{
	if (sptr->is_video) {
		if (MPEG12_ParseSeqHdr(buffer, buflen,
		                       &sptr->have_mpeg2,
		                       &sptr->h,
		                       &sptr->w,
		                       &sptr->frame_rate,
		                       &sptr->bit_rate,
		                       &sptr->par) < 0) {
			sptr->m_stream_id = 0;
			sptr->m_fd = FDNULL;
			return;
		}
		sptr->ticks_per_frame = (u64)(90000.0 / sptr->frame_rate);
		return;
	}

	if (sptr->m_stream_id >= 0xc0) {
		// mpeg audio
		u32 hdr = GF_4CC((u32)buffer[0],buffer[1],buffer[2],buffer[3]);

		sptr->channels = gf_mp3_num_channels(hdr);
		sptr->freq = gf_mp3_sampling_rate(hdr);
		sptr->samples_per_frame = gf_mp3_window_size(hdr);
		sptr->bitrate = gf_mp3_bit_rate(hdr) * 1000; // give bps, not kbps
		sptr->layer = gf_mp3_layer(hdr);
	} else if (sptr->m_stream_id == 0xbd) {
		if (sptr->m_substream_id >= 0xa0) {
			// PCM - ???
		} else if (sptr->m_substream_id >= 0x80) {
			u32 pos;
			GF_AC3Config hdr;
			memset(&hdr, 0, sizeof(GF_AC3Config));
			gf_ac3_parser(buffer, buflen, &pos, &hdr, 0);
			sptr->bitrate = gf_ac3_get_bitrate(hdr.brcode);
			sptr->freq = hdr.sample_rate;
			sptr->channels = hdr.streams[0].channels;
			sptr->samples_per_frame = 256 * 6;
		} else {
			return;
		}
	} else {
		return;
	}
}