Skip to content

Commit

Permalink
fixed potential crash in dasher upon mid-stream config change and avo…
Browse files Browse the repository at this point in the history
…id vtt decoder update if possible - cf #2793
  • Loading branch information
jeanlf committed Apr 8, 2024
1 parent b74b199 commit a4a0c5d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/filters/dasher.c
Expand Up @@ -1324,6 +1324,11 @@ static GF_Err dasher_configure_pid(GF_Filter *filter, GF_FilterPid *pid, Bool is
if (!ctx->bs_switch)
period_switch = GF_TRUE;
break;
//ignore reconfig for these subtitle formats
case GF_CODECID_SIMPLE_TEXT:
case GF_CODECID_WEBVTT:
case GF_CODECID_SUBS_XML:
break;
default:
period_switch = GF_TRUE;
break;
Expand Down Expand Up @@ -7152,6 +7157,8 @@ static GF_Err dasher_setup_period(GF_Filter *filter, GF_DasherCtx *ctx, GF_DashS
//good to go !
for (i=0; i<count; i++) {
GF_DashStream *ds = gf_list_get(ctx->current_period->streams, i);
if (ctx->force_period_switch) return GF_OK;

if (inject_ds && (ds != inject_ds))
continue;
//setup segmentation
Expand Down
8 changes: 7 additions & 1 deletion src/filters/load_text.c
Expand Up @@ -1144,7 +1144,13 @@ static void gf_webvtt_import_header(void *user, const char *config)
{
GF_TXTIn *ctx = (GF_TXTIn *)user;
if (!ctx->hdr_parsed) {
gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_DECODER_CONFIG, &PROP_DATA((char *) config, (u32) (1+strlen(config)) ) );
u32 len = (u32) strlen(config);
//if \n is set, ignore it - this avoids decoder config updates
if ((len<=7) && !strncmp(config, "WEBVTT", 6)) {
gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_DECODER_CONFIG, &PROP_DATA((u8 *) "WEBVTT", 7) );
} else {
gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_DECODER_CONFIG, &PROP_DATA((char *) config, (u32) (1+strlen(config)) ) );
}
ctx->hdr_parsed = GF_TRUE;
gf_webvtt_parser_suspend(ctx->vttparser);
}
Expand Down

0 comments on commit a4a0c5d

Please sign in to comment.