From db4b2bc798388fd22d3ea60eb82c5f894b2b3506 Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Fri, 19 Apr 2019 20:35:54 -0400 Subject: make ReadBlockunsafe and WriteBlockunsafe, ignore invalid pages. --- src/video_core/memory_manager.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/video_core') diff --git a/src/video_core/memory_manager.cpp b/src/video_core/memory_manager.cpp index 095a7e5a4..6c98c6701 100644 --- a/src/video_core/memory_manager.cpp +++ b/src/video_core/memory_manager.cpp @@ -243,8 +243,13 @@ void MemoryManager::ReadBlockUnsafe(GPUVAddr src_addr, void* dest_buffer, while (remaining_size > 0) { const std::size_t copy_amount{ std::min(static_cast(page_size) - page_offset, remaining_size)}; - const u8* src_ptr{page_table.pointers[page_index] + page_offset}; - std::memcpy(dest_buffer, src_ptr, copy_amount); + const u8* page_pointer = page_table.pointers[page_index]; + if (page_pointer) { + const u8* src_ptr{page_pointer + page_offset}; + std::memcpy(dest_buffer, src_ptr, copy_amount); + } else { + std::memset(dest_buffer, 0, copy_amount); + } page_index++; page_offset = 0; dest_buffer = static_cast(dest_buffer) + copy_amount; @@ -288,8 +293,11 @@ void MemoryManager::WriteBlockUnsafe(GPUVAddr dest_addr, const void* src_buffer, while (remaining_size > 0) { const std::size_t copy_amount{ std::min(static_cast(page_size) - page_offset, remaining_size)}; - u8* dest_ptr{page_table.pointers[page_index] + page_offset}; - std::memcpy(dest_ptr, src_buffer, copy_amount); + u8* page_pointer = page_table.pointers[page_index]; + if (page_pointer) { + u8* dest_ptr{page_pointer + page_offset}; + std::memcpy(dest_ptr, src_buffer, copy_amount); + } page_index++; page_offset = 0; src_buffer = static_cast(src_buffer) + copy_amount; -- cgit v1.2.3