Commit 835bc400 authored by Steve Lhomme's avatar Steve Lhomme

libebml2: don't allow adding an element in a Master element if it's not legal in its context

git-svn-id: https://matroska.svn.sourceforge.net/svnroot/matroska/trunk/foundation_src@733 a6f86f6d-0131-4f8e-9e7b-e335508773d5
parent 74294aab
......@@ -32,13 +32,39 @@
ebml_element *EBML_MasterAddElt(ebml_master *Element, const ebml_context *Context, bool_t SetDefault)
{
ebml_element *i;
i = EBML_ElementCreate(Element,Context,SetDefault,NULL);
if (i)
if (EBML_MasterAppend(Element,i)!=ERR_NONE)
#if !defined(NDEBUG)
// check if the sub Context is legal in this Element
bool_t IsLegal = 0;
const ebml_semantic * Semantic;
const ebml_context *ParentContext = Element->Base.Context;
for (Semantic=ParentContext->Semantic;Semantic->eClass;Semantic++)
{
if (Semantic->eClass->Id == Context->Id)
{
IsLegal = 1;
break;
}
}
if (!IsLegal)
{
for (Semantic=ParentContext->GlobalContext;Semantic->eClass;Semantic++)
{
NodeDelete((node*)i);
i = NULL;
if (Semantic->eClass->Id == Context->Id)
{
IsLegal = 1;
break;
}
}
}
if (!IsLegal)
return NULL;
#endif
i = EBML_ElementCreate(Element,Context,SetDefault,NULL);
if (i && EBML_MasterAppend(Element,i)!=ERR_NONE)
{
NodeDelete((node*)i);
i = NULL;
}
return i;
}
......
......@@ -3,7 +3,7 @@
GROUP ebml2_group
{
PROJECT_NAME "libebml2"
PROJECT_VERSION 0.20.3
PROJECT_VERSION 0.21.0
PROJECT_VENDOR "Matroska"
EXPDEFINE HAS_EBML2
......
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