summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2023-09-27 16:37:30 +0200
committerMoonchild <moonchild@palemoon.org>2023-09-27 21:55:28 +0200
commitb6fae242968574324b4f094bdb82961faeecbf6a (patch)
treedaaa1d602c8baebb242723690bf046e009e35204
parent13c6b7422d265596d09cb616b325c801886aa4b0 (diff)
downloaduxp-b6fae242968574324b4f094bdb82961faeecbf6a.tar.gz
[network] Refactor TransactionObserver::OnDataAvailable()RC_20230928
-rw-r--r--netwerk/protocol/http/AlternateServices.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/netwerk/protocol/http/AlternateServices.cpp b/netwerk/protocol/http/AlternateServices.cpp
index cbb28b58de..aee42fe744 100644
--- a/netwerk/protocol/http/AlternateServices.cpp
+++ b/netwerk/protocol/http/AlternateServices.cpp
@@ -755,13 +755,14 @@ TransactionObserver::OnDataAvailable(nsIRequest *aRequest, nsISupports *aContext
nsIInputStream *aStream, uint64_t aOffset, uint32_t aCount)
{
MOZ_ASSERT(NS_IsMainThread());
- uint64_t newLen = aCount + mWKResponse.Length();
+ uint64_t oldLen = static_cast<uint64_t>(mWKResponse.Length());
+ uint64_t newLen = static_cast<uint64_t>(aCount) + oldLen;
if (newLen < MAX_WK) {
- char *startByte = reinterpret_cast<char *>(mWKResponse.BeginWriting()) + mWKResponse.Length();
+ char *startByte = reinterpret_cast<char *>(mWKResponse.BeginWriting()) + oldLen;
uint32_t amtRead;
if (NS_SUCCEEDED(aStream->Read(startByte, aCount, &amtRead))) {
- MOZ_ASSERT(mWKResponse.Length() + amtRead < MAX_WK);
- mWKResponse.SetLength(mWKResponse.Length() + amtRead);
+ MOZ_ASSERT(oldLen + amtRead < MAX_WK);
+ mWKResponse.SetLength(oldLen + amtRead);
LOG(("TransactionObserver onDataAvailable %p read %d of .wk [%d]\n",
this, amtRead, mWKResponse.Length()));
} else {