dec_sub: fix locking for sub_ass_get_extradata

sub->sd can be destroyed and recreated when update_segment is called
inside a lock.

Fixes: f9918b5390
This commit is contained in:
nanahi 2024-04-07 11:57:18 -04:00 committed by Kacper Michajłow
parent dbe377645f
commit 715feea8d8
1 changed files with 4 additions and 1 deletions

View File

@ -445,11 +445,14 @@ char *sub_get_text(struct dec_sub *sub, double pts, enum sd_text_type type)
char *sub_ass_get_extradata(struct dec_sub *sub)
{
mp_mutex_lock(&sub->lock);
if (strcmp(sub->sd->codec->codec, "ass") != 0)
return NULL;
char *extradata = sub->sd->codec->extradata;
int extradata_size = sub->sd->codec->extradata_size;
return talloc_strndup(NULL, extradata, extradata_size);
char *data = talloc_strndup(NULL, extradata, extradata_size);
mp_mutex_unlock(&sub->lock);
return data;
}
struct sd_times sub_get_times(struct dec_sub *sub, double pts)