From eb3e276d3911c4c95d1e2f270bab354440378701 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Fri, 8 Dec 2017 09:17:39 +0100 Subject: [PATCH] BUG/MEDIUM: threads/vars: Fix deadlock in register_name In register_name, before locking the var_names array, we check the variable name validity. So if we try to register an invalid or empty name, we need to return without unlocking it (because it was never locked). This patch must be backported in 1.8. --- src/vars.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/vars.c b/src/vars.c index c8aa5ac89..566ead6ec 100644 --- a/src/vars.c +++ b/src/vars.c @@ -174,8 +174,7 @@ static char *register_name(const char *name, int len, enum vars_scope *scope, /* Check length. */ if (len == 0) { memprintf(err, "Empty variable name cannot be accepted"); - res = NULL; - goto end; + return res; } /* Check scope. */ @@ -207,8 +206,7 @@ static char *register_name(const char *name, int len, enum vars_scope *scope, else { memprintf(err, "invalid variable name '%s'. A variable name must be start by its scope. " "The scope can be 'proc', 'sess', 'txn', 'req' or 'res'", name); - res = NULL; - goto end; + return res; } if (alloc)