From e434d5eee9eaf196a5f4bb8c6118b6be3b84a421 Mon Sep 17 00:00:00 2001 From: Charles McGarvey Date: Thu, 13 May 2010 14:17:40 -0600 Subject: [PATCH] bugfix: writing packets missing some bytes --- src/Moof/Packet.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Moof/Packet.cc b/src/Moof/Packet.cc index 8862f29..8cd45b5 100644 --- a/src/Moof/Packet.cc +++ b/src/Moof/Packet.cc @@ -216,14 +216,16 @@ size_t Packet::write(const void* bytes, size_t size) size_t nBytes = std::min(size, mSize - mW); if (!mBuffer || nBytes < size) { - int numPages = 1 + size / PAGE_SIZE; - int newSize = mSize + numPages * PAGE_SIZE; + int nPages = 1 + size / PAGE_SIZE; + int newSize = mSize + nPages * PAGE_SIZE; char* newBuffer = (char*)realloc(mBuffer, newSize); if (newBuffer) { mBuffer = newBuffer; mSize = newSize; + nBytes = size; } + if (!mBuffer) return 0; } memcpy(&mBuffer[mW], bytes, nBytes); mW += nBytes; -- 2.45.2