This is a fix for very minor bug which may be triggerd only at parsing time
upon parsing failures (allocation failure, or default server name mismatch).
When parsing a named "default-server" instance in _srv_parse_init(), <name> is
allocated via strdup(). If a name mismatch occurs or if srv_alloc() fails,
the function jumps to the <out> label without freeing this string.
Fix this by initializing <name> to NULL at the function start and calling
free(name) in the <out> cleanup block.
This issue was reported by GH #3462.
No need to backport.
int alt_proto = 0;
int tmpl_range_low = 0, tmpl_range_high = 0;
char *errmsg = NULL;
+ char *name = NULL;
+
*srv = NULL;
HA_SPIN_INIT(&newsrv->lock);
}
else {
- char *name;
-
/* Parse optional "name" default-server keyword. */
if (*args[1] && strcmp(args[1], "name") == 0) {
if (!*args[2]) {
else {
/* unnamed default-server instance */
*cur_arg = 1;
- name = NULL;
newsrv = curproxy->defsrv;
}
return 0;
out:
+ free(name);
free(fqdn);
return err_code;
}