Skip to content

Commit

Permalink
dmx_ogg: fix memleak from shadowing variable
Browse files Browse the repository at this point in the history
ossfuzz issue 68257
  • Loading branch information
aureliendavid committed May 21, 2024
1 parent b8497cc commit cd02c12
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/filters/dmx_ogg.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,13 @@ static GF_Err oggdmx_new_stream(GF_Filter *filter, GF_OGGDmxCtx *ctx, ogg_page *
st->parse_headers = st->info.num_init_headers;
switch (st->info.type) {
case GF_CODECID_VORBIS:
if (st->vorbis_parser)
gf_free(st->vorbis_parser);
GF_SAFEALLOC(st->vorbis_parser, GF_VorbisParser);
break;
case GF_CODECID_OPUS:
if (st->opus_cfg)
gf_free(st->opus_cfg);
GF_SAFEALLOC(st->opus_cfg, GF_OpusConfig);
break;
default:
Expand Down Expand Up @@ -813,7 +817,7 @@ GF_Err oggdmx_process(GF_Filter *filter)
gf_bs_write_u16(st->dsi_bs, oggpacket.bytes);
gf_bs_write_data(st->dsi_bs, (char *) oggpacket.packet, oggpacket.bytes);
}

st->parse_headers--;
if (!st->parse_headers) {
st->got_headers = GF_TRUE;
Expand Down Expand Up @@ -878,14 +882,14 @@ GF_Err oggdmx_process(GF_Filter *filter)
}
dst_pck = gf_filter_pck_new_alloc(st->opid, oggpacket.bytes, &output);
if (!dst_pck) return GF_OUT_OF_MEM;

memcpy(output, (char *) oggpacket.packet, oggpacket.bytes);
gf_filter_pck_set_cts(dst_pck, st->recomputed_ts);
//compat with old arch (keep same hashes), to remove once dropping it
if (!gf_sys_old_arch_compat()) {
gf_filter_pck_set_duration(dst_pck, block_size);
}

if (st->info.type == GF_CODECID_VORBIS) {
gf_filter_pck_set_sap(dst_pck, GF_FILTER_SAP_1);
} else if (st->info.type == GF_CODECID_OPUS) {
Expand Down Expand Up @@ -1000,4 +1004,3 @@ const GF_FilterRegister *oggdmx_register(GF_FilterSession *session)
#endif

}

0 comments on commit cd02c12

Please sign in to comment.