From 583bd20f02fabb2b41f42d2ae8feb1994c0e4fb4 Mon Sep 17 00:00:00 2001 From: Subv Date: Fri, 30 Nov 2018 16:06:49 -0500 Subject: Services/VI: Dereferencing an uninitialized std::optional is undefined behavior. Assert that it is not empty before using it in the DequeueBuffer wait callback. --- src/core/hle/service/vi/vi.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp index 5120abfff..412d5b0c9 100644 --- a/src/core/hle/service/vi/vi.cpp +++ b/src/core/hle/service/vi/vi.cpp @@ -542,6 +542,8 @@ private: // Repeat TransactParcel DequeueBuffer when a buffer is available auto buffer_queue = nv_flinger->GetBufferQueue(id); std::optional slot = buffer_queue->DequeueBuffer(width, height); + ASSERT_MSG(slot != std::nullopt, "Could not dequeue buffer."); + IGBPDequeueBufferResponseParcel response{*slot}; ctx.WriteBuffer(response.Serialize()); IPC::ResponseBuilder rb{ctx, 2}; -- cgit v1.2.3