Title: [154516] trunk/Source/WTF
- Revision
- 154516
- Author
- [email protected]
- Date
- 2013-08-23 13:30:23 -0700 (Fri, 23 Aug 2013)
Log Message
Add more validation logic to CompressibleVector
https://bugs.webkit.org/show_bug.cgi?id=120227
Reviewed by Brent Fulgham.
Add a pile of assertions to try on catch whatever is going wrong
in the windows environment or other platforms.
* wtf/Compression.cpp:
(WTF::GenericCompressedData::create):
(WTF::GenericCompressedData::decompress):
* wtf/Compression.h:
(WTF::CompressedVector::decompress):
Modified Paths
Diff
Modified: trunk/Source/WTF/ChangeLog (154515 => 154516)
--- trunk/Source/WTF/ChangeLog 2013-08-23 20:23:35 UTC (rev 154515)
+++ trunk/Source/WTF/ChangeLog 2013-08-23 20:30:23 UTC (rev 154516)
@@ -1,3 +1,19 @@
+2013-08-23 Oliver Hunt <[email protected]>
+
+ Add more validation logic to CompressibleVector
+ https://bugs.webkit.org/show_bug.cgi?id=120227
+
+ Reviewed by Brent Fulgham.
+
+ Add a pile of assertions to try on catch whatever is going wrong
+ in the windows environment or other platforms.
+
+ * wtf/Compression.cpp:
+ (WTF::GenericCompressedData::create):
+ (WTF::GenericCompressedData::decompress):
+ * wtf/Compression.h:
+ (WTF::CompressedVector::decompress):
+
2013-08-23 Alex Christensen <[email protected]>
Re-separating Win32 and Win64 builds.
Modified: trunk/Source/WTF/wtf/Compression.cpp (154515 => 154516)
--- trunk/Source/WTF/wtf/Compression.cpp 2013-08-23 20:23:35 UTC (rev 154515)
+++ trunk/Source/WTF/wtf/Compression.cpp 2013-08-23 20:30:23 UTC (rev 154516)
@@ -71,7 +71,7 @@
size_t currentOffset = OBJECT_OFFSETOF(GenericCompressedData, m_data);
size_t currentCapacity = fastMallocGoodSize(MinimumSize);
Bytef* compressedData = static_cast<Bytef*>(fastMalloc(currentCapacity));
- memset(compressedData, 0, currentCapacity);
+ memset(compressedData, 0, sizeof(GenericCompressedData));
stream.next_out = compressedData + currentOffset;
stream.avail_out = currentCapacity - currentOffset;
@@ -126,8 +126,10 @@
return adoptPtr(result);
}
-bool GenericCompressedData::decompress(uint8_t* destination, size_t bufferSize)
+bool GenericCompressedData::decompress(uint8_t* destination, size_t bufferSize, size_t* decompressedByteCount)
{
+ if (decompressedByteCount)
+ *decompressedByteCount = 0;
z_stream stream;
memset(&stream, 0, sizeof(stream));
stream.zalloc = zAlloc;
@@ -146,6 +148,10 @@
int inflateResult = inflate(&stream, Z_FINISH);
inflateEnd(&stream);
+ ASSERT(stream.total_out <= bufferSize);
+ if (decompressedByteCount)
+ *decompressedByteCount = stream.total_out;
+
if (inflateResult != Z_STREAM_END) {
ASSERT_NOT_REACHED();
return false;
Modified: trunk/Source/WTF/wtf/Compression.h (154515 => 154516)
--- trunk/Source/WTF/wtf/Compression.h 2013-08-23 20:23:35 UTC (rev 154515)
+++ trunk/Source/WTF/wtf/Compression.h 2013-08-23 20:30:23 UTC (rev 154516)
@@ -38,7 +38,7 @@
uint32_t compressedSize() const { return m_compressedSize; }
uint32_t originalSize() const { return m_originalSize; }
- WTF_EXPORT_PRIVATE bool decompress(uint8_t* destination, size_t bufferSize);
+ WTF_EXPORT_PRIVATE bool decompress(uint8_t* destination, size_t bufferSize, size_t* decompressedByteCount = 0);
private:
GenericCompressedData(size_t originalSize, size_t compressedSize)
@@ -65,7 +65,12 @@
void decompress(Vector<T>& destination)
{
Vector<T> output(originalSize() / sizeof(T));
- GenericCompressedData::decompress(reinterpret_cast<uint8_t*>(output.data()), originalSize());
+ ASSERT(output.size() * sizeof(T) == originalSize());
+ size_t decompressedByteCount = 0;
+ GenericCompressedData::decompress(reinterpret_cast<uint8_t*>(output.data()), originalSize(), &decompressedByteCount);
+ ASSERT(decompressedByteCount == originalSize());
+ ASSERT(output.size() * sizeof(T) == decompressedByteCount);
+
destination.swap(output);
}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes