I forgot to malloc space for the NULL.
authorEric Andersen <andersen@codepoet.org>
Wed, 14 Mar 2001 18:57:54 +0000 (18:57 -0000)
committerEric Andersen <andersen@codepoet.org>
Wed, 14 Mar 2001 18:57:54 +0000 (18:57 -0000)
 -Erik

lash.c
sh.c
shell/lash.c

diff --git a/lash.c b/lash.c
index 8edb783694556932c67a87699473a2221ec4bb05..1977d5fdcba0f632bdf65e891cca576d80da8941 100644 (file)
--- a/lash.c
+++ b/lash.c
@@ -936,7 +936,7 @@ char * strsep_space( char *string, int * index)
                return NULL;
        }
 
-       token = xmalloc(*index);
+       token = xmalloc(*index+1);
        token[*index] = '\0';
        strncpy(token, string,  *index); 
 
diff --git a/sh.c b/sh.c
index 8edb783694556932c67a87699473a2221ec4bb05..1977d5fdcba0f632bdf65e891cca576d80da8941 100644 (file)
--- a/sh.c
+++ b/sh.c
@@ -936,7 +936,7 @@ char * strsep_space( char *string, int * index)
                return NULL;
        }
 
-       token = xmalloc(*index);
+       token = xmalloc(*index+1);
        token[*index] = '\0';
        strncpy(token, string,  *index); 
 
index 8edb783694556932c67a87699473a2221ec4bb05..1977d5fdcba0f632bdf65e891cca576d80da8941 100644 (file)
@@ -936,7 +936,7 @@ char * strsep_space( char *string, int * index)
                return NULL;
        }
 
-       token = xmalloc(*index);
+       token = xmalloc(*index+1);
        token[*index] = '\0';
        strncpy(token, string,  *index);