Skip to content
Snippets Groups Projects
Commit a151c446 authored by Eric Vidal's avatar Eric Vidal :speech_balloon:
Browse files

bad memory allocation, please considere \0 framboise

parent a9faf330
No related branches found
No related tags found
No related merge requests found
......@@ -200,7 +200,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
size_t n = env_len(envp) + 1 + byte_count(modifs.s,modifs.len,'\0') ;
if (n > MAXENV) strerr_dief1x(111,"environment string too long") ;
char const *newenv[n] ;
char const *newenv[n + 1] ;
if (!env_merge (newenv, n ,envp,env_len(envp),tmp, modifs.len)) strerr_diefu1sys(111,"build environment") ;
for (i = 0 ; i < genalloc_len(diuint32,&GAENV) ; i++)
......
......@@ -111,7 +111,7 @@ int env_clean(stralloc *src)
int env_split_one(char *line,genalloc *ga,stralloc *sa)
{
size_t slen = strlen(line) ;
char s[slen] ;
char s[slen + 1] ;
memcpy(s,line,slen) ;
s[slen] = 0 ;
......@@ -131,9 +131,7 @@ int env_split_one(char *line,genalloc *ga,stralloc *sa)
if (!obstr_trim(v,'\n')) return 0 ;
tmp.right = sa->len ;
if(!stralloc_catb(sa,v,strlen(v)+1)) return 0 ;
if (!genalloc_append(diuint32,ga,&tmp)) return 0 ;
return 1 ;
}
......@@ -149,7 +147,6 @@ int env_split(genalloc *gaenv,stralloc *saenv,stralloc *src)
if (!*line) continue ;
tmp.len = 0 ;
if (!stralloc_cats(&tmp,line)) goto err ;
/** skip commented line or empty line*/
if (env_clean(&tmp) < 0) continue ;
if (!stralloc_0(&tmp)) goto err ;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment