about summary refs log tree commit diff
path: root/src/env
diff options
context:
space:
mode:
authorAlexander Monakov <amonakov@ispras.ru>2016-03-06 20:22:38 +0300
committerRich Felker <dalias@aerifal.cx>2016-03-06 13:33:52 -0500
commit9543656cc32fda48fc463f332ee20e91eed2b768 (patch)
tree84f79e285a1aa86c18bcc7015f07568afb3f61c2 /src/env
parent589aefa5b061647e8b9ad9bca3aaa8dc6222460a (diff)
downloadmusl-9543656cc32fda48fc463f332ee20e91eed2b768.tar.gz
musl-9543656cc32fda48fc463f332ee20e91eed2b768.tar.xz
musl-9543656cc32fda48fc463f332ee20e91eed2b768.zip
env: avoid leaving dangling pointers in __env_map
This is the minimal fix for __putenv leaving a pointer to freed heap
storage in __env_map array, which could later on lead to errors such
as double-free.
Diffstat (limited to 'src/env')
-rw-r--r--src/env/putenv.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/env/putenv.c b/src/env/putenv.c
index 4042869b..71530426 100644
--- a/src/env/putenv.c
+++ b/src/env/putenv.c
@@ -30,6 +30,7 @@ int __putenv(char *s, int a)
 				}
 			} else {
 				free(__env_map[j]);
+				__env_map[j] = s;
 			}
 		}
 	}