From dfe6b468ec0855f4329e8a54dd79cf0c12939888 Mon Sep 17 00:00:00 2001 From: Jamie Reece Wilson Date: Mon, 23 Oct 2023 11:30:25 +0100 Subject: [PATCH] [*] protocol stack: hardening of buffer flags --- Source/IO/Protocol/AuProtocolPiece.cpp | 8 +++++++- Source/IO/Protocol/AuProtocolStack.cpp | 12 +++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Source/IO/Protocol/AuProtocolPiece.cpp b/Source/IO/Protocol/AuProtocolPiece.cpp index f6509e5b..e1f75d0c 100644 --- a/Source/IO/Protocol/AuProtocolPiece.cpp +++ b/Source/IO/Protocol/AuProtocolPiece.cpp @@ -77,7 +77,13 @@ namespace Aurora::IO::Protocol } } - return this->outputBuffer.Resize(uOutputLength); + this->outputBuffer.flagNoFree = false; + auto bRet = this->outputBuffer.Resize(uOutputLength); + if (!this->uMax.has_value()) + { + this->outputBuffer.flagNoFree = true; + } + return bRet; } void ProtocolPiece::Remove() diff --git a/Source/IO/Protocol/AuProtocolStack.cpp b/Source/IO/Protocol/AuProtocolStack.cpp index 2fee9913..9f1311b3 100644 --- a/Source/IO/Protocol/AuProtocolStack.cpp +++ b/Source/IO/Protocol/AuProtocolStack.cpp @@ -120,6 +120,8 @@ namespace Aurora::IO::Protocol return {}; } + pNew->outputBuffer.flagNoFree = true; + // Circular ref pNew->pOuputWriter = AuMakeShared(AuSPtr(pNew, &pNew->outputBuffer)); @@ -136,7 +138,7 @@ namespace Aurora::IO::Protocol EStreamError Write(const Memory::MemoryViewStreamRead ¶meters) override { - return pStack.lock()->DoTick(AuMakeShared(parameters), pParent.lock()) ? + return pStack.lock()->DoTick(AuMakeSharedThrow(parameters), pParent.lock()) ? EStreamError::eErrorNone : EStreamError::eErrorStreamInterrupted; } @@ -254,6 +256,10 @@ namespace Aurora::IO::Protocol pNew->uMax = uMax; pNew->outputBuffer.flagAlwaysExpandable = pNew->outputBuffer.flagExpandable = 1; } + else + { + pNew->outputBuffer.flagNoFree = true; + } pNew->uStartingSize = uOutputBufferSize; @@ -273,7 +279,7 @@ namespace Aurora::IO::Protocol EStreamError Write(const Memory::MemoryViewStreamRead ¶meters) override { - return pStack.lock()->DoTick(AuMakeShared(parameters), pParent.lock()) ? + return pStack.lock()->DoTick(AuMakeSharedThrow(parameters), pParent.lock()) ? EStreamError::eErrorNone : EStreamError::eErrorStreamInterrupted; } @@ -384,7 +390,7 @@ namespace Aurora::IO::Protocol EStreamError Write(const Memory::MemoryViewStreamRead ¶meters) override { - return pStack.lock()->DoTick(AuMakeShared(parameters), pParent.lock()) ? + return pStack.lock()->DoTick(AuMakeSharedThrow(parameters), pParent.lock()) ? EStreamError::eErrorNone : EStreamError::eErrorStreamInterrupted; }