Module Name: src
Committed By: enami
Date: Wed Dec 2 09:34:51 UTC 2009
Modified Files:
src/lib/libc/stdlib: setenv.c
Log Message:
Retain old variables when failed to allocate memory.
To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/lib/libc/stdlib/setenv.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/lib/libc/stdlib/setenv.c
diff -u src/lib/libc/stdlib/setenv.c:1.31 src/lib/libc/stdlib/setenv.c:1.32
--- src/lib/libc/stdlib/setenv.c:1.31 Sat Nov 1 00:54:47 2008
+++ src/lib/libc/stdlib/setenv.c Wed Dec 2 09:34:51 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: setenv.c,v 1.31 2008/11/01 00:54:47 christos Exp $ */
+/* $NetBSD: setenv.c,v 1.32 2009/12/02 09:34:51 enami Exp $ */
/*
* Copyright (c) 1987, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)setenv.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: setenv.c,v 1.31 2008/11/01 00:54:47 christos Exp $");
+__RCSID("$NetBSD: setenv.c,v 1.32 2009/12/02 09:34:51 enami Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -103,9 +103,9 @@
continue;
size = cc - name;
/* name + `=' + value */
- if ((environ[offset] = malloc(size + l_value + 2)) == NULL)
+ if ((c = malloc(size + l_value + 2)) == NULL)
goto bad;
- c = environ[offset];
+ environ[offset] = c;
(void)memcpy(c, name, size);
c += size;
*c++ = '=';