From cddab7ffb0eda1ae469b10b14ffeb0752a6a8ca8 Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Sun, 20 Oct 2013 15:28:00 -0700 Subject: [PATCH] Fixing free. --- src/xenia/core/memory.cc | 7 ++++++- src/xenia/gpu/d3d11/d3d11_shader.cc | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/xenia/core/memory.cc b/src/xenia/core/memory.cc index bc58be6db..ee88bf808 100644 --- a/src/xenia/core/memory.cc +++ b/src/xenia/core/memory.cc @@ -305,7 +305,7 @@ int xe_memory_heap_free( if (address >= XE_MEMORY_HEAP_LOW && address < XE_MEMORY_HEAP_HIGH) { // Heap allocated address. size_t heap_guard_size = FLAGS_heap_guard_pages * 4096; - p += heap_guard_size; + p -= heap_guard_size; size_t real_size = mspace_usable_size(p); real_size -= heap_guard_size * 2; if (!real_size) { @@ -313,6 +313,11 @@ int xe_memory_heap_free( } XEIGNORE(xe_mutex_lock(memory->heap_mutex)); + if (FLAGS_heap_guard_pages) { + DWORD old_protect; + VirtualProtect(p, heap_guard_size, PAGE_READWRITE, &old_protect); + VirtualProtect(p + heap_guard_size + real_size, heap_guard_size, PAGE_READWRITE, &old_protect); + } mspace_free(memory->heap, p); if (FLAGS_log_heap) { xe_memory_heap_dump(memory); diff --git a/src/xenia/gpu/d3d11/d3d11_shader.cc b/src/xenia/gpu/d3d11/d3d11_shader.cc index 7bac8a788..a25e32478 100644 --- a/src/xenia/gpu/d3d11/d3d11_shader.cc +++ b/src/xenia/gpu/d3d11/d3d11_shader.cc @@ -425,7 +425,7 @@ int D3D11PixelShader::Prepare(xe_gpu_program_cntl_t* program_cntl, NULL, &handle_); if (FAILED(hr)) { - XELOGE("D3D11: failed to create vertex shader"); + XELOGE("D3D11: failed to create pixel shader"); xe_free(byte_code); return 1; }