Fix memory leak
Some [Linux manpages][1] state > This function makes copies of the strings pointed to by name and > value (by contrast with putenv(3)). and the [OpenGroup][2] manpage also states that the strings are copied, so indeed they can and should be freed afterwards. [1]: https://man7.org/linux/man-pages/man3/setenv.3.html [2]: https://pubs.opengroup.org/onlinepubs/009695399/functions/setenv.htmlmaster
parent
3aa92b1559
commit
c944d64234
|
@ -147,6 +147,8 @@ static void update_environment(array local_env)
|
|||
memcpy(value, pos_eq + 1, value_length);
|
||||
value[value_length] = '\0';
|
||||
setenv(name, value, 1); /* 1 means overwrite */
|
||||
free(name);
|
||||
free(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue