From 8268db667d3505d6a9f7bde706038e3177ca6e3f Mon Sep 17 00:00:00 2001 From: Steve Lhomme Date: Sun, 18 Feb 2024 13:51:07 +0100 Subject: [PATCH] add missing filter checks in UpdateSize() All filtered out elements should give a size of 0. The result is usually not used but the result should be consistent. --- ebml/EbmlDate.h | 5 ++++- src/EbmlBinary.cpp | 5 ++++- src/EbmlMaster.cpp | 3 +++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ebml/EbmlDate.h b/ebml/EbmlDate.h index 03bd5705..8153fd50 100644 --- a/ebml/EbmlDate.h +++ b/ebml/EbmlDate.h @@ -46,7 +46,10 @@ class EBML_DLL_API EbmlDate : public EbmlElementDefaultSameStorage /*! \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 diff --git a/src/EbmlBinary.cpp b/src/EbmlBinary.cpp index e1ab8edc..48f97835 100644 --- a/src/EbmlBinary.cpp +++ b/src/EbmlBinary.cpp @@ -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(); } diff --git a/src/EbmlMaster.cpp b/src/EbmlMaster.cpp index ca2faf7e..6313eff2 100644 --- a/src/EbmlMaster.cpp +++ b/src/EbmlMaster.cpp @@ -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())