setenv overrite & unsetenv does not free the old key-value string which lead memory leak
The use of valgrind and POC programs proved that SETENV and UNSETENV had a memory leak problem. int main(int argc, char **argv) { setenv("test_setenv", "test_setenv", 1); setenv("test_setenv", "test_setenv2", 1); setenv("test_setenv", "test_setenv22222", 1); putenv("test_setenv"); return 0; } ==18333== HEAP SUMMARY: ==18333== in use at exit: 147 bytes in 5 blocks ==18333== total heap usage: 6 allocs, 1 frees, 191 bytes allocated ==18333== ==18333== 78 bytes in 3 blocks are definitely lost in loss record 3 of 3 ==18333== at 0x482DAA4: malloc (vg_replace_malloc.c:381) ==18333== by 0x48D3020: __add_to_environ (in /lib/libuClibc-0.9.33.so) ==18333== ==18333== LEAK SUMMARY: ==18333== definitely lost: 78 bytes in 3 blocks ==18333== indirectly lost: 0 bytes in 0 blocks ==18333== possibly lost: 0 bytes in 0 blocks ==18333== still reachable: 69 bytes in 2 blocks ==18333== suppressed: 0 bytes in 0 blocks