Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Unified Diff: third_party/woff2/src/woff2_common.cc

Issue 1873123002: Update woff2 to 4e698b8 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update BUILD.gn (win8 build fix?) Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/woff2/src/woff2_common.h ('k') | third_party/woff2/src/woff2_compress.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/woff2/src/woff2_common.cc
diff --git a/third_party/woff2/src/woff2_common.cc b/third_party/woff2/src/woff2_common.cc
index 39dc54e6f313cff062d924bfb2d29ddbaa2fc267..eba6a46e213980d55a90bc0101702dea64c67a4e 100644
--- a/third_party/woff2/src/woff2_common.cc
+++ b/third_party/woff2/src/woff2_common.cc
@@ -23,7 +23,8 @@ namespace woff2 {
uint32_t ComputeULongSum(const uint8_t* buf, size_t size) {
uint32_t checksum = 0;
- for (size_t i = 0; i < size; i += 4) {
+ size_t aligned_size = size & ~3;
+ for (size_t i = 0; i < aligned_size; i += 4) {
#if (defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__))
uint32_t v = *reinterpret_cast<const uint32_t*>(buf + i);
checksum += (((v & 0xFF) << 24) | ((v & 0xFF00) << 8) |
@@ -35,6 +36,16 @@ uint32_t ComputeULongSum(const uint8_t* buf, size_t size) {
(buf[i + 2] << 8) | buf[i + 3];
#endif
}
+
+ // treat size not aligned on 4 as if it were padded to 4 with 0's
+ if (size != aligned_size) {
+ uint32_t v = 0;
+ for (size_t i = aligned_size; i < size; ++i) {
+ v |= buf[i] << (24 - 8 * (i & 3));
+ }
+ checksum += v;
+ }
+
return checksum;
}
« no previous file with comments | « third_party/woff2/src/woff2_common.h ('k') | third_party/woff2/src/woff2_compress.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698