Skip to content

Commit 7a6f636

Browse files
committed
fixes #2633 - 3 segv + memleak
1 parent 7edc40f commit 7a6f636

File tree

4 files changed

+29
-26
lines changed

4 files changed

+29
-26
lines changed

Diff for: src/filters/isoffin_load.c

+4-7
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ static void isor_get_chapters(GF_ISOFile *file, GF_FilterPid *opid)
8989
GF_TextSample *txt = gf_isom_parse_text_sample(bs);
9090
if (txt) {
9191
times.vals[i] = (u32) s->DTS;
92-
names.vals[i] = gf_strdup(txt->text);
92+
names.vals[i] = gf_strdup(txt->text ? txt->text : "");
9393
gf_isom_delete_text_sample(txt);
9494
}
9595
gf_bs_del(bs);
@@ -1105,7 +1105,7 @@ static void isor_declare_track(ISOMReader *read, ISOMChannel *ch, u32 track, u32
11051105
gf_odf_desc_del((GF_Descriptor *)lang_desc);
11061106
lang_desc = NULL;
11071107
}
1108-
1108+
11091109
if (read->smode != MP4DMX_SINGLE) {
11101110
if ((codec_id==GF_CODECID_LHVC) || (codec_id==GF_CODECID_HEVC)) {
11111111
Bool signal_lhv = (read->smode==MP4DMX_SPLIT) ? GF_TRUE : GF_FALSE;
@@ -1750,7 +1750,7 @@ GF_Err isor_declare_objects(ISOMReader *read)
17501750
GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[IsoMedia] No suitable tracks in file\n"));
17511751
return GF_NOT_SUPPORTED;
17521752
}
1753-
1753+
17541754
/*if cover art, declare a video pid*/
17551755
if (gf_isom_apple_get_tag(read->mov, GF_ISOM_ITUNE_COVER_ART, &tag, &tlen)==GF_OK) {
17561756

@@ -1853,7 +1853,7 @@ Bool isor_declare_item_properties(ISOMReader *read, ISOMChannel *ch, u32 item_id
18531853

18541854
if (read->itemid)
18551855
gf_filter_pid_set_property(pid, GF_PROP_PID_ITEM_ID, &PROP_UINT(item_id));
1856-
1856+
18571857
if ((item_codecid==GF_CODECID_HEVC) && gf_isom_meta_item_has_ref(read->mov, GF_TRUE, 0, item_id, GF_ISOM_REF_TBAS)) {
18581858
gf_filter_pid_set_property(pid, GF_PROP_PID_TILE_BASE, &PROP_BOOL(GF_TRUE));
18591859
}
@@ -1948,6 +1948,3 @@ Bool isor_declare_item_properties(ISOMReader *read, ISOMChannel *ch, u32 item_id
19481948
}
19491949

19501950
#endif // !defined(GPAC_DISABLE_ISOM) && !defined(GPAC_DISABLE_MP4DMX)
1951-
1952-
1953-

Diff for: src/filters/mux_isom.c

+9-10
Original file line numberDiff line numberDiff line change
@@ -1027,7 +1027,7 @@ static GF_Err mp4_mux_setup_pid(GF_Filter *filter, GF_FilterPid *pid, Bool is_tr
10271027
gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_STREAM_TYPE, &PROP_UINT(GF_STREAM_FILE) );
10281028

10291029
mux_assign_mime_file_ext(pid, ctx->opid, ISOM_FILE_EXT, ISOM_FILE_MIME, NULL);
1030-
1030+
10311031
gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_DASH_MODE, NULL);
10321032
//we dispatch timing in milliseconds
10331033
gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_TIMESCALE, &PROP_UINT(1000));
@@ -1080,7 +1080,7 @@ static GF_Err mp4_mux_setup_pid(GF_Filter *filter, GF_FilterPid *pid, Bool is_tr
10801080
GF_FilterEvent evt;
10811081
GF_SAFEALLOC(tkw, TrackWriter);
10821082
if (!tkw) return GF_OUT_OF_MEM;
1083-
1083+
10841084
gf_list_add(ctx->tracks, tkw);
10851085
tkw->ipid = pid;
10861086
tkw->fake_track = !is_true_pid;
@@ -2615,7 +2615,7 @@ static GF_Err mp4_mux_setup_pid(GF_Filter *filter, GF_FilterPid *pid, Bool is_tr
26152615
return e;
26162616
}
26172617
}
2618-
2618+
26192619
if (xps_inband) {
26202620
//this will cleanup all PS in avcC / svcC
26212621
gf_isom_avc_set_inband_config(ctx->file, tkw->track_num, tkw->stsd_idx, (xps_inband==XPS_IB_BOTH) ? GF_TRUE : GF_FALSE);
@@ -3213,7 +3213,7 @@ static GF_Err mp4_mux_setup_pid(GF_Filter *filter, GF_FilterPid *pid, Bool is_tr
32133213
GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[MP4Mux] muxing unknown codec ID %s, using generic sample entry with 4CC \"%s\"\n", gf_codecid_name(codec_id), gf_4cc_to_str(m_subtype) ));
32143214
}
32153215
}
3216-
3216+
32173217
e = gf_isom_new_generic_sample_description(ctx->file, tkw->track_num, (char *)src_url, NULL, &udesc, &tkw->stsd_idx);
32183218
if (gpac_meta_dsi) gf_free(gpac_meta_dsi);
32193219

@@ -3762,7 +3762,7 @@ static GF_Err mp4_mux_setup_pid(GF_Filter *filter, GF_FilterPid *pid, Bool is_tr
37623762
if (add_chap) {
37633763
gf_isom_add_chapter(ctx->file, 0, start_time, p2->value.string_list.vals[j]);
37643764
}
3765-
if (add_tk) {
3765+
if (add_tk && p2->value.string_list.vals[j]) {
37663766
GF_TextSample tx;
37673767
memset(&tx, 0, sizeof(tx));
37683768
tx.text = p2->value.string_list.vals[j];
@@ -4363,7 +4363,7 @@ static GF_Err mp4_mux_cenc_update(GF_MP4MuxCtx *ctx, TrackWriter *tkw, GF_Filter
43634363
tkw->has_seig = GF_TRUE;
43644364
}
43654365
} else {
4366-
4366+
43674367
e = GF_OK;
43684368
//multikey ALWAYS uses seig
43694369
if (tkw->cenc_ki->value.data.ptr[0])
@@ -5014,7 +5014,7 @@ static GF_Err mp4_mux_process_sample(GF_MP4MuxCtx *ctx, TrackWriter *tkw, GF_Fil
50145014
tkw->gdr_type = sap_type;
50155015
}
50165016
}
5017-
5017+
50185018
subs = gf_filter_pck_get_property(pck, GF_PROP_PCK_SUBS);
50195019
if (subs) {
50205020
//if no AUDelim nal and inband header injection, push new subsample
@@ -7107,7 +7107,7 @@ static void mp4_mux_config_timing(GF_MP4MuxCtx *ctx)
71077107
if (blocking_refs && has_ready) {
71087108
GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[MP4Mux] Blocking input packets present, aborting initial timing sync\n"));
71097109
}
7110-
//this may be quite long until we have a packet in case input pid is video encoding
7110+
//this may be quite long until we have a packet in case input pid is video encoding
71117111
else if (ctx->config_retry_start && (gf_sys_clock() - ctx->config_retry_start > 10000)) {
71127112
GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[MP4Mux] No input packets present on one or more inputs for more than 10s, aborting initial timing sync\n"));
71137113
} else {
@@ -7908,7 +7908,7 @@ static GF_Err mp4_mux_done(GF_MP4MuxCtx *ctx, Bool is_final)
79087908
}
79097909

79107910
gf_isom_purge_track_reference(ctx->file, tkw->track_num);
7911-
7911+
79127912
if (ctx->importer && ctx->dur.num && ctx->dur.den) {
79137913
u64 mdur = gf_isom_get_media_duration(ctx->file, tkw->track_num);
79147914
u64 pdur = gf_isom_get_track_duration(ctx->file, tkw->track_num);
@@ -8392,4 +8392,3 @@ const GF_FilterRegister *mp4mx_register(GF_FilterSession *session)
83928392
return NULL;
83938393
}
83948394
#endif // GPAC_DISABLE_ISOM_WRITE
8395-

Diff for: src/isomedia/media.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,8 @@ GF_Err Media_GetESD(GF_MediaBox *mdia, u32 sampleDescIndex, GF_ESD **out_esd, Bo
392392
return GF_ISOM_INVALID_MEDIA;
393393
} else {
394394
GF_LASeRSampleEntryBox*ptr = (GF_LASeRSampleEntryBox*)entry;
395+
if (!ptr || !ptr->lsr_config || !ptr->lsr_config->hdr_size)
396+
return GF_ISOM_INVALID_MEDIA;
395397
esd = gf_odf_desc_esd_new(2);
396398
*out_esd = esd;
397399
esd->decoderConfig->streamType = GF_STREAM_SCENE;
@@ -1071,7 +1073,7 @@ GF_Err Media_AddSample(GF_MediaBox *mdia, u64 data_offset, const GF_ISOSample *s
10711073
e = stbl_AddChunkOffset(mdia, sampleNumber, StreamDescIndex, data_offset, sample->nb_pack);
10721074
if (e) return e;
10731075
}
1074-
1076+
10751077
if (!syncShadowNumber) return GF_OK;
10761078
if (!stbl->ShadowSync) {
10771079
stbl->ShadowSync = (GF_ShadowSyncBox *) gf_isom_box_new_parent(&stbl->child_boxes, GF_ISOM_BOX_TYPE_STSH);

Diff for: src/isomedia/tx3g.c

+13-8
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,14 @@ GF_Err gf_isom_get_text_description(GF_ISOFile *movie, u32 trackNumber, u32 desc
102102
(*out_desc)->displayFlags = txt->displayFlags;
103103
(*out_desc)->vert_justif = txt->vertical_justification;
104104
(*out_desc)->horiz_justif = txt->horizontal_justification;
105-
(*out_desc)->font_count = txt->font_table->entry_count;
106-
(*out_desc)->fonts = (GF_FontRecord *) gf_malloc(sizeof(GF_FontRecord) * txt->font_table->entry_count);
107-
for (i=0; i<txt->font_table->entry_count; i++) {
108-
(*out_desc)->fonts[i].fontID = txt->font_table->fonts[i].fontID;
109-
if (txt->font_table->fonts[i].fontName)
110-
(*out_desc)->fonts[i].fontName = gf_strdup(txt->font_table->fonts[i].fontName);
105+
if (txt->font_table && txt->font_table->entry_count) {
106+
(*out_desc)->font_count = txt->font_table->entry_count;
107+
(*out_desc)->fonts = (GF_FontRecord *) gf_malloc(sizeof(GF_FontRecord) * txt->font_table->entry_count);
108+
for (i=0; i<txt->font_table->entry_count; i++) {
109+
(*out_desc)->fonts[i].fontID = txt->font_table->fonts[i].fontID;
110+
if (txt->font_table->fonts[i].fontName)
111+
(*out_desc)->fonts[i].fontName = gf_strdup(txt->font_table->fonts[i].fontName);
112+
}
111113
}
112114
}
113115
return GF_OK;
@@ -663,9 +665,12 @@ GF_TextSample *gf_isom_parse_text_sample(GF_BitStream *bs)
663665
}
664666

665667
while (gf_bs_available(bs)) {
666-
GF_Box *a;
668+
GF_Box *a = NULL;
667669
GF_Err e = gf_isom_box_parse(&a, bs);
668-
if (e) break;
670+
if (e) {
671+
if (a) gf_isom_box_del(a);
672+
break;
673+
}
669674

670675
switch (a->type) {
671676
case GF_ISOM_BOX_TYPE_STYL:

0 commit comments

Comments
 (0)