mirror of
https://github.com/haproxy/haproxy.git
synced 2026-05-19 16:36:07 -04:00
BUG/MINOR: tools: free previously allocated strings on strdup failure in backup_env()
When strdup() fails after some entries have already been strdup'd, the function returned -1 without freeing previously allocated strings. Added cleanup loop to free all previously strdup'd entries and reset init_env. This can be backported to 3.1.
This commit is contained in:
parent
d5efce7a13
commit
eb97e21a8f
1 changed files with 7 additions and 0 deletions
|
|
@ -7562,6 +7562,13 @@ int backup_env(void)
|
|||
if (*tmp == NULL) {
|
||||
ha_alert("Cannot allocate memory to backup env variable '%s'.\n",
|
||||
*env);
|
||||
tmp = init_env;
|
||||
while (*tmp) {
|
||||
free(*tmp);
|
||||
tmp++;
|
||||
}
|
||||
free(init_env);
|
||||
init_env = NULL;
|
||||
return -1;
|
||||
}
|
||||
tmp++;
|
||||
|
|
|
|||
Loading…
Reference in a new issue