diff options
author | Joshua Ashton <joshua@froggi.es> | 2021-02-20 10:24:12 +0300 |
---|---|---|
committer | Joshua Ashton <joshua@froggi.es> | 2021-02-20 10:28:20 +0300 |
commit | 9c30c7650b1b3feb4f12277b63424f0ee0ecb508 (patch) | |
tree | 66201345e4d88978b436b83449e6b25b49c568c8 | |
parent | b18c27f0994edb68e666360cd352f4ee75a55a91 (diff) |
[dxvk] Fix barrier refcounting issueasan2
Before this commit, imgslices stored a raw pointer to a DXVK image.
Needs to be ref-counted otherwise we can end up with a use after free here in the pointer comparison:
- operator == in Rc with a raw pointer will cast the raw to a Rc
- Because it was a raw pointer, and not ref-tracked it may have already been freed
- Comparing with a raw pointer directly would be bad as we could get another image allocated at the same address so we must ref track for barrier lists
-rw-r--r-- | src/dxvk/dxvk_barrier.cpp | 6 | ||||
-rw-r--r-- | src/dxvk/dxvk_barrier.h | 2 |
2 files changed, 4 insertions, 4 deletions
diff --git a/src/dxvk/dxvk_barrier.cpp b/src/dxvk/dxvk_barrier.cpp index 00cb5c70..dc062466 100644 --- a/src/dxvk/dxvk_barrier.cpp +++ b/src/dxvk/dxvk_barrier.cpp @@ -73,7 +73,7 @@ namespace dxvk { m_imgBarriers.push_back(barrier); } - m_imgSlices.push_back({ image.ptr(), subresources, access }); + m_imgSlices.push_back({ image, subresources, access }); } @@ -152,8 +152,8 @@ namespace dxvk { acquire.m_imgBarriers.push_back(barrier); DxvkAccessFlags access(DxvkAccess::Read, DxvkAccess::Write); - release.m_imgSlices.push_back({ image.ptr(), subresources, access }); - acquire.m_imgSlices.push_back({ image.ptr(), subresources, access }); + release.m_imgSlices.push_back({ image, subresources, access }); + acquire.m_imgSlices.push_back({ image, subresources, access }); } diff --git a/src/dxvk/dxvk_barrier.h b/src/dxvk/dxvk_barrier.h index e97669c6..91b63e49 100644 --- a/src/dxvk/dxvk_barrier.h +++ b/src/dxvk/dxvk_barrier.h @@ -93,7 +93,7 @@ namespace dxvk { }; struct ImgSlice { - DxvkImage* image; + Rc<DxvkImage> image; VkImageSubresourceRange subres; DxvkAccessFlags access; }; |