Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/EbmlBinary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,25 +72,27 @@ filepos_t EbmlBinary::UpdateSize(const ShouldWrite & writeFilter, bool /* bForce

filepos_t EbmlBinary::ReadData(IOCallback & input, ScopeMode ReadFully)
{
const auto SizeToRead = GetSize();
if (Data != nullptr) {
free(Data);
Data = nullptr;
}

if (ReadFully == SCOPE_NO_DATA) {
return GetSize();
return SizeToRead;
}

if (!GetSize()) {
if (!SizeToRead) {
SetValueIsSet();
return 0;
}

Data = (GetSize() < std::numeric_limits<std::size_t>::max()) ? static_cast<binary *>(malloc(GetSize())) : nullptr;
Data = (SizeToRead < std::numeric_limits<std::size_t>::max()) ? static_cast<binary *>(malloc(SizeToRead)) : nullptr;
if (Data == nullptr)
throw std::runtime_error("Error allocating data");
input.readFully(Data, SizeToRead);
SetValueIsSet();
return input.read(Data, GetSize());
return SizeToRead;
}

bool EbmlBinary::operator==(const EbmlBinary & ElementToCompare) const
Expand Down
Loading