From a3c97dfad2b85774281dbfcc5f50b06cd8eceade Mon Sep 17 00:00:00 2001 From: Richard Stanway Date: Sat, 15 Jan 2022 22:56:23 +0000 Subject: [PATCH] libobs-opengl: Miscellaneous static analysis fixes Detected by PVS Studio. --- libobs-opengl/gl-shader.c | 13 ++++++++----- libobs-opengl/gl-x11-egl.c | 4 +--- libobs-opengl/gl-x11-glx.c | 5 +---- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/libobs-opengl/gl-shader.c b/libobs-opengl/gl-shader.c index cc6eed808..6d7a2a18d 100644 --- a/libobs-opengl/gl-shader.c +++ b/libobs-opengl/gl-shader.c @@ -228,12 +228,15 @@ static bool gl_shader_init(struct gs_shader *shader, char *infoLog = malloc(sizeof(char) * infoLength); - GLsizei returnedLength = 0; - glGetShaderInfoLog(shader->obj, infoLength, &returnedLength, - infoLog); - blog(LOG_ERROR, "Error compiling shader:\n%s\n", infoLog); + if (infoLog) { + GLsizei returnedLength = 0; + glGetShaderInfoLog(shader->obj, infoLength, + &returnedLength, infoLog); + blog(LOG_ERROR, "Error compiling shader:\n%s\n", + infoLog); - free(infoLog); + free(infoLog); + } success = false; } diff --git a/libobs-opengl/gl-x11-egl.c b/libobs-opengl/gl-x11-egl.c index f8b35a363..5ad27bddd 100644 --- a/libobs-opengl/gl-x11-egl.c +++ b/libobs-opengl/gl-x11-egl.c @@ -159,7 +159,6 @@ static xcb_get_geometry_reply_t *get_window_geometry(xcb_connection_t *xcb_conn, return 0; } - free(error); return reply; } @@ -371,8 +370,7 @@ static Display *open_windowless_display(Display *platform_display) return display; error: - if (display) - XCloseDisplay(display); + XCloseDisplay(display); return NULL; } diff --git a/libobs-opengl/gl-x11-glx.c b/libobs-opengl/gl-x11-glx.c index 25ad11329..22dcfc903 100644 --- a/libobs-opengl/gl-x11-glx.c +++ b/libobs-opengl/gl-x11-glx.c @@ -163,7 +163,6 @@ static xcb_get_geometry_reply_t *get_window_geometry(xcb_connection_t *xcb_conn, return 0; } - free(error); return reply; } @@ -195,7 +194,6 @@ static bool gl_context_create(struct gl_platform *plat) } plat->context = context; - plat->display = display; plat->pbuffer = glXCreatePbuffer(display, config[0], ctx_pbuffer_attribs); @@ -273,8 +271,7 @@ static Display *open_windowless_display(void) return display; error: - if (display) - XCloseDisplay(display); + XCloseDisplay(display); return NULL; }