From 2c6081225b50e476ee61bb46e251aff6daf63a75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Wed, 20 Jan 2016 16:14:14 +0100 Subject: [PATCH] shader: fix potential leak MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Found thanks to llvm scan-build. Signed-off-by: Marc-André Lureau --- src/vrend_shader.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/vrend_shader.c b/src/vrend_shader.c index f0ce025..0e7078d 100644 --- a/src/vrend_shader.c +++ b/src/vrend_shader.c @@ -188,11 +188,13 @@ static inline bool fs_emit_layout(struct dump_ctx *ctx) static char *strcat_realloc(char *str, const char *catstr) { - str = realloc(str, strlen(str) + strlen(catstr) + 1); - if (!str) + char *new = realloc(str, strlen(str) + strlen(catstr) + 1); + if (!new) { + free(str); return NULL; - strcat(str, catstr); - return str; + } + strcat(new, catstr); + return new; } static char *add_str_to_glsl_main(struct dump_ctx *ctx, char *buf)