diff --git a/content/media/nsMediaCache.cpp b/content/media/nsMediaCache.cpp index acf105bed4d..575fe21b5c3 100644 --- a/content/media/nsMediaCache.cpp +++ b/content/media/nsMediaCache.cpp @@ -2226,7 +2226,7 @@ nsMediaCacheStream::Read(char* aBuffer, PRUint32 aCount, PRUint32* aBytes) gMediaCache->NoteBlockUsage(this, cacheBlock, mCurrentMode, TimeStamp::Now()); PRInt64 offset = cacheBlock*BLOCK_SIZE + offsetInStreamBlock; - NS_ASSERTION(size >= 0 && size <= PR_INT32_MAX, "Size out of range."); + NS_ABORT_IF_FALSE(size >= 0 && size <= PR_INT32_MAX, "Size out of range."); nsresult rv = gMediaCache->ReadCacheFile(offset, aBuffer + count, PRInt32(size), &bytes); if (NS_FAILED(rv)) { if (count == 0) @@ -2265,7 +2265,7 @@ nsMediaCacheStream::ReadFromCache(char* aBuffer, PRUint32 streamBlock = PRUint32(streamOffset/BLOCK_SIZE); PRUint32 offsetInStreamBlock = PRUint32(streamOffset - streamBlock*BLOCK_SIZE); - PRInt32 size = NS_MIN(aCount - count, BLOCK_SIZE - offsetInStreamBlock); + PRInt64 size = NS_MIN(aCount - count, BLOCK_SIZE - offsetInStreamBlock); if (mStreamLength >= 0) { // Don't try to read beyond the end of the stream @@ -2273,7 +2273,9 @@ nsMediaCacheStream::ReadFromCache(char* aBuffer, if (bytesRemaining <= 0) { return NS_ERROR_FAILURE; } - size = NS_MIN(size, PRInt32(bytesRemaining)); + size = NS_MIN(size, bytesRemaining); + // Clamp size until 64-bit file size issues (bug 500784) are fixed. + size = NS_MIN(size, PRInt64(PR_INT32_MAX)); } PRInt32 bytes; @@ -2292,7 +2294,8 @@ nsMediaCacheStream::ReadFromCache(char* aBuffer, return NS_ERROR_FAILURE; } PRInt64 offset = cacheBlock*BLOCK_SIZE + offsetInStreamBlock; - nsresult rv = gMediaCache->ReadCacheFile(offset, aBuffer + count, size, &bytes); + NS_ABORT_IF_FALSE(size >= 0 && size <= PR_INT32_MAX, "Size out of range."); + nsresult rv = gMediaCache->ReadCacheFile(offset, aBuffer + count, PRInt32(size), &bytes); if (NS_FAILED(rv)) { return rv; }