mirror of
git://git.musl-libc.org/musl
synced 2025-01-09 16:19:50 +00:00
free allocations in clearenv
This aligns clearenv with the Linux man page by setting 'environ' rather than '*environ' to NULL, and stops it from leaking entries allocated by the libc.
This commit is contained in:
parent
8e932792c9
commit
cc0dbd5f09
8
src/env/clearenv.c
vendored
8
src/env/clearenv.c
vendored
@ -1,10 +1,14 @@
|
|||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include "libc.h"
|
||||||
|
|
||||||
extern char **__environ;
|
static void dummy(char *old, char *new) {}
|
||||||
|
weak_alias(dummy, __env_rm_add);
|
||||||
|
|
||||||
int clearenv()
|
int clearenv()
|
||||||
{
|
{
|
||||||
__environ[0] = 0;
|
char **e = __environ;
|
||||||
|
__environ = 0;
|
||||||
|
if (e) while (*e) __env_rm_add(*e++, 0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user