diff --git a/src/common/env.c b/src/common/env.c
index 0410743aab7fae8b714f58980d869c30eff8e2c2..ebf32edcc8c5228f3267b7fdcd9bb85d28c4b5f8 100644
--- a/src/common/env.c
+++ b/src/common/env.c
@@ -280,7 +280,7 @@ setenvfs(const char *fmt, ...)
 
 int setenvf(char ***envp, const char *name, const char *fmt, ...)
 {
-	char *str = NULL, *value;
+	char *value;
 	va_list ap;
 	int size, rc;
 
@@ -301,15 +301,7 @@ int setenvf(char ***envp, const char *name, const char *fmt, ...)
 		else
 			rc = 1;
 	} else {
-		/* XXX Space is allocated on the heap and will never
-		 * be reclaimed.
-		 * Also you can not use xmalloc here since some of the
-		 * external api's like perl will crap out when they
-		 * try to free it.
-		 */
-		str = malloc(size);	/* CLANG false positive */
-		snprintf(str, size, "%s=%s", name, value);
-		rc = putenv(str);
+		rc = setenv(name, value, 1);
 	}
 
 	xfree(value);