Bug 1056919 - Crash in memcpy | mozilla::net::CacheFileChunk::OnDataRead(mozilla::net::CacheFileHandle*, char*, tag_nsresult). r=honzab, a=sledru
authorMichal Novotny <michal.novotny@gmail.com>
Tue, 16 Sep 2014 20:37:39 +0200
changeset 216770 62d020eff891
parent 216769 75eddbd6dc80
child 216771 e85a6d689148
push id3906
push userryanvm@gmail.com
push date2014-09-17 15:11 +0000
treeherdermozilla-beta@62d020eff891 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershonzab, sledru
bugs1056919
milestone33.0
Bug 1056919 - Crash in memcpy | mozilla::net::CacheFileChunk::OnDataRead(mozilla::net::CacheFileHandle*, char*, tag_nsresult). r=honzab, a=sledru
netwerk/cache2/CacheFileChunk.cpp
--- a/netwerk/cache2/CacheFileChunk.cpp
+++ b/netwerk/cache2/CacheFileChunk.cpp
@@ -536,17 +536,17 @@ CacheFileChunk::OnDataRead(CacheFileHand
                   MOZ_CRASH("Unexpected error in validity map!");
                 }
                 memcpy(mBuf + invalidOffset, mRWBuf + invalidOffset,
                        invalidLength);
               }
               invalidOffset = mValidityMap[i].Offset() + mValidityMap[i].Len();
             }
             if (invalidOffset < mRWBufSize) {
-              invalidLength = invalidOffset - mRWBufSize;
+              invalidLength = mRWBufSize - invalidOffset;
               memcpy(mBuf + invalidOffset, mRWBuf + invalidOffset,
                      invalidLength);
             }
             mValidityMap.Clear();
 
             free(mRWBuf);
             mRWBuf = nullptr;
             mRWBufSize = 0;