more safety on the Binary buffer handling in case we run out of memory

git-svn-id: https://matroska.svn.sourceforge.net/svnroot/matroska/trunk/libebml@491 a6f86f6d-0131-4f8e-9e7b-e335508773d5
This commit is contained in:
Steve Lhomme 2010-08-10 19:04:58 +00:00
parent df5620c733
commit 42044e93f5
3 changed files with 6 additions and 3 deletions

View File

@ -1,6 +1,7 @@
2010-08-xx robux4
New 1.1.1 version:
- no need to put the internal code of EbmlCrc32 in the public header
- more safety on the Binary buffer handling in case we run out of memory
2010-07-xx robux4
New 1.1.0 version:

View File

@ -37,6 +37,7 @@
#include <cassert>
#include "ebml/EbmlBinary.h"
#include "ebml/StdIOCallback.h"
START_LIBEBML_NAMESPACE
@ -84,14 +85,15 @@ filepos_t EbmlBinary::ReadData(IOCallback & input, ScopeMode ReadFully)
if (Data != NULL)
free(Data);
if (ReadFully == SCOPE_NO_DATA)
if (ReadFully == SCOPE_NO_DATA || !GetSize())
{
Data = NULL;
return GetSize();
}
Data = (binary *)malloc(GetSize() * sizeof(binary));
assert(Data != NULL);
if (Data == NULL)
throw CRTError::CRTError("Error allocating data");
SetValueIsSet();
return input.read(Data, GetSize());
}

View File

@ -278,7 +278,7 @@ EbmlElement *EbmlMaster::FindFirstElt(const EbmlCallbacks & Callbacks, bool bCre
size_t Index;
for (Index = 0; Index < ElementList.size(); Index++) {
if (EbmlId(*(ElementList[Index])) == EBML_INFO_ID(Callbacks))
if (ElementList[Index] && EbmlId(*(ElementList[Index])) == EBML_INFO_ID(Callbacks))
return ElementList[Index];
}