X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/81a21a9a97d8633f6d6231e31fdb6e328d0d3ff2..9322ba2854211794c27fae9468768b80b767c211:/sbr/putenv.c diff --git a/sbr/putenv.c b/sbr/putenv.c index fb4a77ce..5266d63e 100644 --- a/sbr/putenv.c +++ b/sbr/putenv.c @@ -2,8 +2,6 @@ /* * putenv.c -- (un)set an envariable * - * $Id$ - * * This code is Copyright (c) 2002, by the authors of nmh. See the * COPYRIGHT file in the root directory of the nmh distribution for * complete copyright information. @@ -21,16 +19,16 @@ int m_putenv (char *, char *); int unputenv (char *); static int nvmatch (char *, char *); +/* FIXME: These functions leak memory. No easy fix since they might not + * be malloc'd. Switch to setenv(3) and unsetenv(3). */ int m_putenv (char *name, char *value) { - register int i; - register char **ep, **nep, *cp; - - cp = mh_xmalloc ((size_t) (strlen (name) + strlen (value) + 2)); + int i; + char **ep, **nep, *cp; - sprintf (cp, "%s=%s", name, value); + cp = concat(name, "=", value, NULL); for (ep = environ, i = 0; *ep; ep++, i++) if (nvmatch (name, *ep)) {