BUG/MINOR: hlua: Fix memory leaks on error path when parsing a lua action

hen an error occurred in action_register_lua(), the allocated hlua rule and
arguments must be released to avoid memory leaks.

This patch may be backported in all stable versions.
diff --git a/src/hlua.c b/src/hlua.c
index 693ada5..c0cd125 100644
--- a/src/hlua.c
+++ b/src/hlua.c
@@ -7581,7 +7581,7 @@
 	rule->arg.hlua_rule = calloc(1, sizeof(*rule->arg.hlua_rule));
 	if (!rule->arg.hlua_rule) {
 		memprintf(err, "out of memory error");
-		return ACT_RET_PRS_ERR;
+		goto error;
 	}
 
 	/* Memory for arguments. */
@@ -7589,7 +7589,7 @@
 					   sizeof(*rule->arg.hlua_rule->args));
 	if (!rule->arg.hlua_rule->args) {
 		memprintf(err, "out of memory error");
-		return ACT_RET_PRS_ERR;
+		goto error;
 	}
 
 	/* Reference the Lua function and store the reference. */
@@ -7599,12 +7599,12 @@
 	for (i = 0; i < fcn->nargs; i++) {
 		if (*args[*cur_arg] == '\0') {
 			memprintf(err, "expect %d arguments", fcn->nargs);
-			return ACT_RET_PRS_ERR;
+			goto error;
 		}
 		rule->arg.hlua_rule->args[i] = strdup(args[*cur_arg]);
 		if (!rule->arg.hlua_rule->args[i]) {
 			memprintf(err, "out of memory error");
-			return ACT_RET_PRS_ERR;
+			goto error;
 		}
 		(*cur_arg)++;
 	}
@@ -7613,6 +7613,17 @@
 	rule->action = ACT_CUSTOM;
 	rule->action_ptr = hlua_action;
 	return ACT_RET_PRS_OK;
+
+  error:
+	if (rule->arg.hlua_rule) {
+		if (rule->arg.hlua_rule->args) {
+			for (i = 0; i < fcn->nargs; i++)
+				ha_free(&rule->arg.hlua_rule->args[i]);
+			ha_free(&rule->arg.hlua_rule->args);
+		}
+		ha_free(&rule->arg.hlua_rule);
+	}
+	return ACT_RET_PRS_ERR;
 }
 
 static enum act_parse_ret action_register_service_http(const char **args, int *cur_arg, struct proxy *px,