LibC: setenv don't require 'overwrite' for non-existing value

Instead, require 'overwrite' only for already-existing values. I.e.,
require 'overwrite' only when overwriting.
This commit is contained in:
Ben Wiederhake 2020-08-01 13:46:27 +02:00 committed by Andreas Kling
parent 3d5abae17b
commit b4b39258ac
Notes: sideshowbarker 2024-07-19 04:24:35 +09:00

View File

@ -290,7 +290,7 @@ int unsetenv(const char* name)
int setenv(const char* name, const char* value, int overwrite)
{
if (!overwrite && !getenv(name))
if (!overwrite && getenv(name))
return 0;
auto length = strlen(name) + strlen(value) + 2;
auto* var = (char*)malloc(length);