projects
/
pspp
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
opendir-safer.c: don't clobber errno; don't close negative FD
[pspp]
/
lib
/
setenv.c
diff --git
a/lib/setenv.c
b/lib/setenv.c
index 5ad22c5c10072bd461a2f77d45bf812b763acec8..173d95f28b4853599777e28f7d20fdb7d32cd904 100644
(file)
--- a/
lib/setenv.c
+++ b/
lib/setenv.c
@@
-1,4
+1,4
@@
-/* Copyright (C) 1992,
1995-1999,2000-2003,2005-2009
Free Software Foundation, Inc.
+/* Copyright (C) 1992,
1995-2003, 2005-2011
Free Software Foundation, Inc.
This file is part of the GNU C Library.
This program is free software: you can redistribute it and/or modify
This file is part of the GNU C Library.
This program is free software: you can redistribute it and/or modify
@@
-15,8
+15,14
@@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#if !_LIBC
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#if !_LIBC
+# define _GL_USE_STDLIB_ALLOC 1
# include <config.h>
#endif
# include <config.h>
#endif
+
+/* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc
+ optimizes away the name == NULL test below. */
+#define _GL_ARG_NONNULL(params)
+
#include <alloca.h>
/* Specification. */
#include <alloca.h>
/* Specification. */
@@
-107,8
+113,8
@@
int
__add_to_environ (const char *name, const char *value, const char *combined,
int replace)
{
__add_to_environ (const char *name, const char *value, const char *combined,
int replace)
{
-
register
char **ep;
-
register
size_t size;
+ char **ep;
+ size_t size;
const size_t namelen = strlen (name);
const size_t vallen = value != NULL ? strlen (value) + 1 : 0;
const size_t namelen = strlen (name);
const size_t vallen = value != NULL ? strlen (value) + 1 : 0;
@@
-142,6
+148,9
@@
__add_to_environ (const char *name, const char *value, const char *combined,
: realloc (last_environ, (size + 2) * sizeof (char *)));
if (new_environ == NULL)
{
: realloc (last_environ, (size + 2) * sizeof (char *)));
if (new_environ == NULL)
{
+ /* It's easier to set errno to ENOMEM than to rely on the
+ 'malloc-posix' and 'realloc-posix' gnulib modules. */
+ __set_errno (ENOMEM);
UNLOCK;
return -1;
}
UNLOCK;
return -1;
}
@@
-244,7
+253,7
@@
__add_to_environ (const char *name, const char *value, const char *combined,
if (np == NULL)
#endif
{
if (np == NULL)
#endif
{
- np = malloc (namelen + 1 + vallen);
+ np =
(char *)
malloc (namelen + 1 + vallen);
if (np == NULL)
{
#if defined USE_TSEARCH && !defined _LIBC
if (np == NULL)
{
#if defined USE_TSEARCH && !defined _LIBC