From c7b86b2a959660eddf5cbb831926b69a8d883bd1 Mon Sep 17 00:00:00 2001 From: Harsha Raghu Date: Mon, 22 Apr 2024 00:04:46 +0530 Subject: [PATCH] fix: fix crashes and memory leaks in client_core gfx --- alvr/client_core/cpp/graphics.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/alvr/client_core/cpp/graphics.cpp b/alvr/client_core/cpp/graphics.cpp index 4870c7f47e..3e043776ef 100644 --- a/alvr/client_core/cpp/graphics.cpp +++ b/alvr/client_core/cpp/graphics.cpp @@ -558,18 +558,18 @@ bool ovrProgram_Create(ovrProgram *program, } void ovrProgram_Destroy(ovrProgram *program) { - if (program->streamProgram != 0) { + if (GL_TRUE == glIsProgram(program->streamProgram)) { GL(glDeleteProgram(program->streamProgram)); - program->streamProgram = 0; } - if (program->VertexShader != 0) { + program->streamProgram = 0; + if (GL_TRUE == glIsShader(program->VertexShader)) { GL(glDeleteShader(program->VertexShader)); - program->VertexShader = 0; } - if (program->FragmentShader != 0) { + program->VertexShader = 0; + if (GL_TRUE == glIsShader(program->FragmentShader)) { GL(glDeleteShader(program->FragmentShader)); - program->FragmentShader = 0; } + program->FragmentShader = 0; } void ovrRenderer_Create(ovrRenderer *renderer, @@ -823,18 +823,18 @@ void prepareLobbyRoom(int viewWidth, void destroyRenderers() { if (g_ctx.streamRenderer) { ovrRenderer_Destroy(g_ctx.streamRenderer.get()); - g_ctx.streamRenderer.release(); + g_ctx.streamRenderer.reset(); } if (g_ctx.lobbyRenderer) { ovrRenderer_Destroy(g_ctx.lobbyRenderer.get()); - g_ctx.lobbyRenderer.release(); + g_ctx.lobbyRenderer.reset(); } } void streamStartNative(FfiStreamConfig config) { if (g_ctx.streamRenderer) { ovrRenderer_Destroy(g_ctx.streamRenderer.get()); - g_ctx.streamRenderer.release(); + g_ctx.streamRenderer.reset(); } for (int eye = 0; eye < 2; eye++) {