Skip to content

Commit

Permalink
add missing filter checks in UpdateSize()
Browse files Browse the repository at this point in the history
All filtered out elements should give a size of 0.
The result is usually not used but the result should be consistent.
  • Loading branch information
robUx4 committed Feb 18, 2024
1 parent 3a015a4 commit 8268db6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
5 changes: 4 additions & 1 deletion ebml/EbmlDate.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ class EBML_DLL_API EbmlDate : public EbmlElementDefaultSameStorage<std::int64_t>
/*!
\note no Default date handled
*/
filepos_t UpdateSize(const ShouldWrite & /* writeFilter */, bool /* bForceRender = false */) override {
filepos_t UpdateSize(const ShouldWrite & writeFilter, bool /* bForceRender = false */) override {
if (!CanWrite(writeFilter))
return 0;

if(!ValueIsSet())
SetSize_(0);
else
Expand Down
5 changes: 4 additions & 1 deletion src/EbmlBinary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,11 @@ filepos_t EbmlBinary::RenderData(IOCallback & output, bool /* bForceRender */, c
/*!
\note no Default binary value handled
*/
std::uint64_t EbmlBinary::UpdateSize(const ShouldWrite & /* writeFilter */, bool /* bForceRender */)
std::uint64_t EbmlBinary::UpdateSize(const ShouldWrite & writeFilter, bool /* bForceRender */)
{
if (!CanWrite(writeFilter))
return 0;

return GetSize();
}

Expand Down
3 changes: 3 additions & 0 deletions src/EbmlMaster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ bool EbmlMaster::PushElement(EbmlElement & element)

std::uint64_t EbmlMaster::UpdateSize(const ShouldWrite & writeFilter, bool bForceRender)
{
if (!CanWrite(writeFilter))
return 0;

SetSize_(0);

if (!IsFiniteSize())
Expand Down

0 comments on commit 8268db6

Please sign in to comment.