From 87fee9594936aecd2955d69bc4603f8b00f65570 Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Sun, 14 Sep 2014 23:48:30 +0200 Subject: [PATCH] Fix setenv(3) error case. --- libc/stdlib/setenv.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libc/stdlib/setenv.cpp b/libc/stdlib/setenv.cpp index 335abdbb..aeff0f26 100644 --- a/libc/stdlib/setenv.cpp +++ b/libc/stdlib/setenv.cpp @@ -177,6 +177,9 @@ extern "C" int setenv(const char* name, const char* value, int overwrite) } // Append the new entry to the environ array. - bool result = set_entry_at(environ, __environ_used++, name, name_length, value, value_length); - return result ? 0 : -1; + if ( !set_entry_at(environ, __environ_used, + name, name_length, + value, value_length) ) + return -1; + return __environ_used++, 0; }