* unsetenv() was moving too much memory, thus corrupting the data after
its allocation. * Added TODO to use a benaphore. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25478 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
bf681d149a
commit
b4e5605e0a
@ -23,6 +23,7 @@
|
|||||||
return err;
|
return err;
|
||||||
|
|
||||||
|
|
||||||
|
// TODO: Use benaphore!
|
||||||
static sem_id sEnvLock;
|
static sem_id sEnvLock;
|
||||||
static bool sCopied;
|
static bool sCopied;
|
||||||
|
|
||||||
@ -212,9 +213,11 @@ unsetenv(const char *name)
|
|||||||
|
|
||||||
env = find_variable(name, length, &index);
|
env = find_variable(name, length, &index);
|
||||||
if (env != NULL) {
|
if (env != NULL) {
|
||||||
// we don't free the memory for the slot, we just move the array contents
|
// we don't free the memory for the slot, we just move the array
|
||||||
|
// contents
|
||||||
free(env);
|
free(env);
|
||||||
memmove(environ + index, environ + index + 1, sizeof(char *) * (count_variables() + 1));
|
memmove(environ + index, environ + index + 1,
|
||||||
|
sizeof(char *) * (count_variables() - index));
|
||||||
}
|
}
|
||||||
|
|
||||||
release_sem(sEnvLock);
|
release_sem(sEnvLock);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user