Allocate space for arrays of type "char *", not "char **".
Rev 1.8 made the type consistently incorrect. Noted by: Ben Smithurst <ben@scientia.demon.co.uk>
This commit is contained in:
parent
4fcb0bd623
commit
f80ecf46c4
@ -27,7 +27,7 @@ static const char rcsid[] =
|
||||
char **
|
||||
env_init()
|
||||
{
|
||||
register char **p = (char **) malloc(sizeof(char **));
|
||||
register char **p = (char **) malloc(sizeof(char *));
|
||||
|
||||
if (p)
|
||||
p[0] = NULL;
|
||||
@ -56,7 +56,7 @@ env_copy(envp)
|
||||
|
||||
for (count = 0; envp[count] != NULL; count++)
|
||||
;
|
||||
p = (char **) malloc((count+1) * sizeof(char **)); /* 1 for the NULL */
|
||||
p = (char **) malloc((count+1) * sizeof(char *)); /* 1 for the NULL */
|
||||
if (p == NULL) {
|
||||
errno = ENOMEM;
|
||||
return NULL;
|
||||
@ -116,7 +116,7 @@ env_set(envp, envstr)
|
||||
* array.
|
||||
*/
|
||||
p = (char **) realloc((void *) envp,
|
||||
(unsigned) ((count+1) * sizeof(char **)));
|
||||
(unsigned) ((count+1) * sizeof(char *)));
|
||||
if (p == NULL) {
|
||||
/* XXX env_free(envp); */
|
||||
errno = ENOMEM;
|
||||
|
Loading…
x
Reference in New Issue
Block a user