From 3ddc8ad68a48568a991d57870bd2cda2c649c7a2 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Wed, 13 Dec 2023 01:04:54 -0600 Subject: [PATCH] Fix crash if pl_vulkan_create() fails --- app/streaming/video/ffmpeg-renderers/plvk.cpp | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/app/streaming/video/ffmpeg-renderers/plvk.cpp b/app/streaming/video/ffmpeg-renderers/plvk.cpp index 0f90cbda..4b650e45 100644 --- a/app/streaming/video/ffmpeg-renderers/plvk.cpp +++ b/app/streaming/video/ffmpeg-renderers/plvk.cpp @@ -96,17 +96,19 @@ PlVkRenderer::PlVkRenderer(IFFmpegRenderer* backendRenderer) : PlVkRenderer::~PlVkRenderer() { - for (int i = 0; i < (int)SDL_arraysize(m_Overlays); i++) { - if (m_Overlays[i].hasOverlay) { - pl_tex_destroy(m_Vulkan->gpu, &m_Overlays[i].overlay.tex); + if (m_Vulkan != nullptr) { + for (int i = 0; i < (int)SDL_arraysize(m_Overlays); i++) { + if (m_Overlays[i].hasOverlay) { + pl_tex_destroy(m_Vulkan->gpu, &m_Overlays[i].overlay.tex); + } + if (m_Overlays[i].hasStagingOverlay) { + pl_tex_destroy(m_Vulkan->gpu, &m_Overlays[i].stagingOverlay.tex); + } } - if (m_Overlays[i].hasStagingOverlay) { - pl_tex_destroy(m_Vulkan->gpu, &m_Overlays[i].stagingOverlay.tex); - } - } - for (int i = 0; i < (int)SDL_arraysize(m_Textures); i++) { - pl_tex_destroy(m_Vulkan->gpu, &m_Textures[i]); + for (int i = 0; i < (int)SDL_arraysize(m_Textures); i++) { + pl_tex_destroy(m_Vulkan->gpu, &m_Textures[i]); + } } pl_renderer_destroy(&m_Renderer);