Mail Archives: djgpp-workers/1999/08/09/09:57:14
> Why should we silently ignore a NULL pointer? If anything, we should
> set errno to EFAULT. `environ' being NULL is a valid situation, but
> passing a NULL `name' is not.
>
Fair enough. Here's a revised version:
*** src/libc/ansi/stdlib/getenv.c.orig Fri Nov 24 22:21:18 1995
--- src/libc/ansi/stdlib/getenv.c Mon Aug 9 08:34:30 1999
***************
*** 1,6 ****
--- 1,8 ----
+ /* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#include <stdlib.h>
#include <string.h>
+ #include <errno.h>
extern char **environ;
*************** char *
*** 8,13 ****
--- 10,21 ----
getenv(const char *name)
{
int i;
+
+ if (name == 0)
+ {
+ errno = EFAULT;
+ return 0;
+ }
if (environ == 0)
return 0;
---
Mark Elbrecht, snowball3 AT bigfoot DOT com
http://snowball.frogspace.net/
- Raw text -