Skip to content

Commit 5d9aac4

Browse files
committed
[MERGE chakra-core#2206 @MikeHolman] fix issue where LocalAlloc call was passing page count instead of byte count
Merge pull request chakra-core#2206 from MikeHolman:localallocfix While writing this API I changed parameter from being page count to byte size, but missed updating this call site
2 parents fc5b62c + df75ded commit 5d9aac4

1 file changed

Lines changed: 2 additions & 13 deletions

File tree

lib/Common/Memory/PageAllocator.cpp

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1592,17 +1592,11 @@ PageAllocatorBase<TVirtualAlloc, TSegment, TPageSegment>::MemSetLocal(_In_ void
15921592
}
15931593

15941594
#if _WIN32
1595-
// SegmentBase<SectionAllocWrapper>, PageSegmentBase<SectionAllocWrapper>
15961595
template<>
15971596
void
15981597
PageAllocatorBase<SectionAllocWrapper>::MemSetLocal(_In_ void *dst, int val, size_t sizeInBytes)
15991598
{
1600-
size_t pages = sizeInBytes / AutoSystemInfo::PageSize;
1601-
if (sizeInBytes % AutoSystemInfo::PageSize != 0)
1602-
{
1603-
++pages;
1604-
}
1605-
LPVOID localAddr = this->GetVirtualAllocator()->AllocLocal(dst, pages);
1599+
LPVOID localAddr = this->GetVirtualAllocator()->AllocLocal(dst, sizeInBytes);
16061600
if (localAddr == nullptr)
16071601
{
16081602
MemoryOperationLastError::CheckProcessAndThrowFatalError(this->processHandle);
@@ -1618,12 +1612,7 @@ template<>
16181612
void
16191613
PageAllocatorBase<PreReservedSectionAllocWrapper>::MemSetLocal(_In_ void *dst, int val, size_t sizeInBytes)
16201614
{
1621-
size_t pages = sizeInBytes / AutoSystemInfo::PageSize;
1622-
if (sizeInBytes % AutoSystemInfo::PageSize != 0)
1623-
{
1624-
++pages;
1625-
}
1626-
LPVOID localAddr = this->GetVirtualAllocator()->AllocLocal(dst, pages);
1615+
LPVOID localAddr = this->GetVirtualAllocator()->AllocLocal(dst, sizeInBytes);
16271616
if (localAddr == nullptr)
16281617
{
16291618
MemoryOperationLastError::CheckProcessAndThrowFatalError(this->processHandle);

0 commit comments

Comments
 (0)