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
f47dc39cf5
commit
d02e530b50
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=59785
@ -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…
Reference in New Issue
Block a user