diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index a1b7f56634..292bd29583 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -920,7 +920,13 @@ static int ebml_parse_nest(MatroskaDemuxContext *matroska, EbmlSyntax *syntax, break; case EBML_STR: case EBML_UTF8: - *(char **)((char *)data+syntax[i].data_offset) = av_strdup(syntax[i].def.s); + // the default may be NULL + if (syntax[i].def.s) { + uint8_t **dst = (uint8_t**)((uint8_t*)data + syntax[i].data_offset); + *dst = av_strdup(syntax[i].def.s); + if (!*dst) + return AVERROR(ENOMEM); + } break; }