summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2016-01-20 16:14:14 +0100
committerDave Airlie <airlied@redhat.com>2016-02-10 11:59:40 +1000
commit2c6081225b50e476ee61bb46e251aff6daf63a75 (patch)
treedbaf56afcaf272b67fe8effaab2b3bea106397d7
parent602e68705ebdb0963ee4643aa4098f58cbf98b45 (diff)
shader: fix potential leak
Found thanks to llvm scan-build. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
-rw-r--r--src/vrend_shader.c10
1 files 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)