Leaking memory is not a "solution". Ever. Maybe for a commercial problem. But not for one in systems API design.
If you copy, provide a new interface. It's time-honoured and proven in Unix to give *_r() ones in such a case.
If you copy, provide a new interface. It's time-honoured and proven in Unix to give *_r() ones in such a case.
A proper solution would be to either nuke put/setenv() in the C standard library or redesign the *env() calls entirely, but that would break existing programs.