Skip to content

Commit 5aee954

Browse files
committed
Make sure to zero-fill the page in PostReadPage()
1 parent 389896f commit 5aee954

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

worker.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1989,12 +1989,23 @@ DWORD ChunkDiskWorker::PostReadPage(ChunkOpState& state)
19891989
if (err != ERROR_NOT_FOUND)
19901990
{
19911991
// page hit or error
1992-
if (h != INVALID_HANDLE_VALUE) CloseChunkAsync(chunk_idx, false);
1992+
if (h != INVALID_HANDLE_VALUE)
1993+
{
1994+
CloseChunkAsync(chunk_idx, false);
1995+
}
1996+
else if (err == ERROR_SUCCESS)
1997+
{
1998+
memset(ptr, 0, service_.bases[0].PageBytes(1));
1999+
}
19932000
return err;
19942001
}
19952002

19962003
// page miss
1997-
if (h == INVALID_HANDLE_VALUE) return ERROR_SUCCESS;
2004+
if (h == INVALID_HANDLE_VALUE)
2005+
{
2006+
// page already zero-filled
2007+
return ERROR_SUCCESS;
2008+
}
19982009

19992010
const auto length_bytes = u32(service_.bases[0].PageBytes(1));
20002011
auto bytes_read = DWORD();
@@ -2022,7 +2033,6 @@ DWORD ChunkDiskWorker::PostReadPage(ChunkOpState& state)
20222033
if (state.kind != WRITE_PAGE_PARTIAL)
20232034
{
20242035
// page hit, chunk not found or empty
2025-
// page already zero-filled
20262036
auto& base = service_.bases[0];
20272037
auto length_bytes = base.BlockBytes(state.end_off - state.start_off);
20282038
memcpy(state.buffer, recast<u8*>(ptr) + base.BlockBytes(state.start_off), length_bytes);

0 commit comments

Comments
 (0)