Commit 2337e4db authored by François Grisez's avatar François Grisez
Browse files

Fix crash when mkvstream read a MKV files which some non-mandatory field are not written

parent 7ddbbace
...@@ -328,7 +328,7 @@ static void _load_modules(nodemodule *modules) { ...@@ -328,7 +328,7 @@ static void _load_modules(nodemodule *modules) {
static int _parse_headers(MKVReader *obj) { static int _parse_headers(MKVReader *obj) {
ebml_element *level0 = NULL, *level1 = NULL; ebml_element *level0 = NULL, *level1 = NULL;
ebml_parser_context pctx, seg_pctx; ebml_parser_context pctx, seg_pctx;
char doc_type[MAX_MKV_STRING_LENGTH]; char doc_type[9];
int doc_type_version; int doc_type_version;
int err; int err;
int upper_level = 0; int upper_level = 0;
...@@ -359,13 +359,13 @@ static int _parse_headers(MKVReader *obj) { ...@@ -359,13 +359,13 @@ static int _parse_headers(MKVReader *obj) {
ms_error("MKVParser: missing elements in the EBML header"); ms_error("MKVParser: missing elements in the EBML header");
goto fail; goto fail;
} }
EBML_StringGet((ebml_string *)EBML_MasterFindChild((ebml_master *)level0, &EBML_ContextDocType), doc_type, MAX_MKV_STRING_LENGTH); EBML_StringGet((ebml_string *)EBML_MasterGetChild((ebml_master *)level0, &EBML_ContextDocType), doc_type, sizeof(doc_type));
err = strcmp(doc_type, "matroska"); err = strcmp(doc_type, "matroska");
if(err != 0) { if(err != 0) {
ms_error("MKVParser: not a matroska file"); ms_error("MKVParser: not a matroska file");
goto fail; goto fail;
} }
doc_type_version = EBML_IntegerValue((ebml_integer *)EBML_MasterFindChild((ebml_master *)level0, &EBML_ContextDocTypeVersion)); doc_type_version = EBML_IntegerValue((ebml_integer *)EBML_MasterGetChild((ebml_master *)level0, &EBML_ContextDocTypeVersion));
NodeDelete((node *)level0); NodeDelete((node *)level0);
level0 = EBML_FindNextElement(obj->file, &pctx, &upper_level, FALSE); level0 = EBML_FindNextElement(obj->file, &pctx, &upper_level, FALSE);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment