]> Dogcows Code - chaz/yoink/commitdiff
bugfix: writing packets missing some bytes
authorCharles McGarvey <chazmcgarvey@brokenzipper.com>
Thu, 13 May 2010 20:17:40 +0000 (14:17 -0600)
committerCharles McGarvey <chazmcgarvey@brokenzipper.com>
Thu, 13 May 2010 20:17:40 +0000 (14:17 -0600)
src/Moof/Packet.cc

index 8862f29bc9ba918ef23fb4608d539681fbb4f90a..8cd45b53baff4e71a9e5ac5a4e3381ebb59972b4 100644 (file)
@@ -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;
This page took 0.02489 seconds and 4 git commands to generate.