mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1021612 - Fix offset calculation in CacheFileMetadata::ReadMetadata(), r=honzab
This commit is contained in:
parent
8f6948b38d
commit
6266244a13
@ -185,11 +185,17 @@ CacheFileMetadata::ReadMetadata(CacheFileMetadataListener *aListener)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// round offset to 4k blocks
|
||||
int64_t offset = (size / kAlignSize) * kAlignSize;
|
||||
// Set offset so that we read at least kMinMetadataRead if the file is big
|
||||
// enough.
|
||||
int64_t offset;
|
||||
if (size < kMinMetadataRead) {
|
||||
offset = 0;
|
||||
} else {
|
||||
offset = size - kMinMetadataRead;
|
||||
}
|
||||
|
||||
if (size - offset < kMinMetadataRead && offset > kAlignSize)
|
||||
offset -= kAlignSize;
|
||||
// round offset to kAlignSize blocks
|
||||
offset = (offset / kAlignSize) * kAlignSize;
|
||||
|
||||
mBufSize = size - offset;
|
||||
mBuf = static_cast<char *>(moz_xmalloc(mBufSize));
|
||||
|
Loading…
Reference in New Issue
Block a user