Memleak

if putenv() fails then memory allocated by strdup() remains unfreed. 
if strdup() fails then putenv() gets NULL as an argument and its behaviour is not defined in this case.
This patch fixes both cases.
Though if any of these functions fails, the module is not configured properly. This situation may need to be addressed.