зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1412942 - pad Mac font data when checksumming. r=jfkthame
MozReview-Commit-ID: 3941eAWNXoR
This commit is contained in:
Родитель
3aac464b5a
Коммит
1eba4acd8d
|
@ -175,7 +175,7 @@ CalcTableChecksum(const uint32_t *tableStart, uint32_t length, bool skipChecksum
|
|||
{
|
||||
uint32_t sum = 0L;
|
||||
const uint32_t *table = tableStart;
|
||||
const uint32_t *end = table+((length+3) & ~3) / sizeof(uint32_t);
|
||||
const uint32_t *end = table + length / sizeof(uint32_t);
|
||||
while (table < end) {
|
||||
if (skipChecksumAdjust && (table - tableStart) == 2) {
|
||||
table++;
|
||||
|
@ -183,6 +183,15 @@ CalcTableChecksum(const uint32_t *tableStart, uint32_t length, bool skipChecksum
|
|||
sum += CFSwapInt32BigToHost(*table++);
|
||||
}
|
||||
}
|
||||
|
||||
// The length is not 4-byte aligned, but we still must process the remaining bytes.
|
||||
if (length & 3) {
|
||||
// Pad with zero before adding to the checksum.
|
||||
uint32_t last = 0;
|
||||
memcpy(&last, end, length & 3);
|
||||
sum += CFSwapInt32BigToHost(last);
|
||||
}
|
||||
|
||||
return sum;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче