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.
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++;