Fix UB with guest-less Texture/Buffers in MarkGpuDirty

As there was no check for the lack of a `GuestTexture`/`GuestBuffer`, it would lead to UB when a texture/buffer that had no guest such as the `zeroTexture` from `GraphicsContext` would be marked as dirty they would cause a call to `NCE::RetrapRegions` with a `nullptr` handle that would be dereferenced and cause a segmentation fault.
This commit is contained in:
PixelyIon 2022-04-15 20:17:32 +05:30
parent 372ab8befa
commit 8ccef733ff
2 changed files with 2 additions and 2 deletions

View File

@ -45,7 +45,7 @@ namespace skyline::gpu {
} }
void Buffer::MarkGpuDirty() { void Buffer::MarkGpuDirty() {
if (dirtyState == DirtyState::GpuDirty || externallySynchronized) { if (dirtyState == DirtyState::GpuDirty || externallySynchronized || !guest) {
externallySynchronized = false; // We want to handle synchronize internally after the GPU work is done externallySynchronized = false; // We want to handle synchronize internally after the GPU work is done
return; return;
} }

View File

@ -348,7 +348,7 @@ namespace skyline::gpu {
} }
void Texture::MarkGpuDirty() { void Texture::MarkGpuDirty() {
if (dirtyState == DirtyState::GpuDirty) if (dirtyState == DirtyState::GpuDirty || !guest)
return; return;
gpu.state.nce->RetrapRegions(*trapHandle, false); gpu.state.nce->RetrapRegions(*trapHandle, false);
dirtyState = DirtyState::GpuDirty; dirtyState = DirtyState::GpuDirty;