From: Charles McGarvey Date: Thu, 13 May 2010 20:17:40 +0000 (-0600) Subject: bugfix: writing packets missing some bytes X-Git-Url: https://git.dogcows.com/gitweb?a=commitdiff_plain;h=e434d5eee9eaf196a5f4bb8c6118b6be3b84a421;p=chaz%2Fyoink bugfix: writing packets missing some bytes --- 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;